#APCER. MayanCalendar

MayanCalendar

 Problem Statement:

The Maya is a Mesoamerican civilization noted for its art, architecture, mathematics and astronomical systems. In the recent past their calendar system has been quite in the news because of the misinterpretation of their Long count calendar, which gave way for a popular belief that a cataclysm will take place on December 21, 2012. Many speculated it will mark the end of human civilization!

But we now know it did not happen as we are still alive! Note this date, it falls on a Friday.Since human civilization may have ended on that day, we will call every Friday the 21st as a vulnerable day. Similarly we define a safe day which is not a vulnerable day. Your task is given two years M and N, you need to find how many safe days are there between any given years M and N (inclusive).

To honor the Mayan civilization you should write the total number of safe days in Mayan Long Count notation. The Long Count calendar identifies a date by counting the number of days from the Mayan creation date. But instead of using a base-10 scheme like Western numbering, the Long Count days were tallied in a modified base-20 scheme. As a matter of fact December 21, 2012 is simply the day that the calendar will go to the next B'ak'tun. You do not need to bother about creation date but simply represent your answer in Long Count notation. See the below example and table for clarification:


Days

Place

Long Count unit

1

                            0

1 K'in

20

                            1

1 Winal

360

                            2

1 Tun

7,200

                            3

1 K'atun

144,000

                            4

1 B'ak'tun

Table of Long Count units

Check the full list here: http://en.wikipedia.org/wiki/Maya_calendar (not needed for this problem).

Conversion:

For this problem you can consider numbers in the Long Count to be represented in base 20 except for the Winal place which is to be taken in base 18. Below example will clarify how to convert your answer into Long Count Notation.

For instance, if safe days comes out to be 1454 your output must be:  "0.0.4.0.14" (without quotes).    (1*14 + 20*0 + 360*4 + 7200*0 + 144000*0 = 1454)

For 360 output must be "0.0.1.0.0"(without quotes).

For 20 output must be “0.0.0.1.0” (without quotes).

As you can see all the places are in base 10 except the 1st place which is base 18.


Input Specification: First line of input contains 0<T<500, number of test cases on which your program will run. Followed by two integers M and N where  1901<=M, N<=2300, where M<=N, if M=N you need to tell for that particular year only.


Output Specification: For every test case output: A single line containing the number of safe days between the year M and N(inclusive) in Long count notation explained above. It is guaranteed that the number of safe days could always be represented up to fourth place (B'ak'tun place) in the above given notation.

"a.b.c.d.e" (without quotes) where    0<= a, b, c, e <20, 0<=d<18.

Facts:

  1. Jan 1, 1901 was Tuesday.
  2. All calculations must be done following Gregorian calendar which is the current standard calendar in the world including ours.
  3. If you don't know how to calculate leap year see this link: <http://en.wikipedia.org/wiki/Leap_year>

Sample Test cases:

Input:

3

2011 2012

2012 2012

2000 2020

Output:

0.0.2.0.7

0.0.1.0.4

0.1.1.3.14


Explanation:

For case 1: there are 727 safe days which can be represented as 0.0.2.0.7

There are 4 vulnerable days between: January 2011 to December 2012.

These are: 21st January 2011, 21st October 2011, 21st September 2012 and 21st December 2012.

Total number of days between: January 2011 to December 2012 are 731.

Therefore the number of safe days are 731-4 = 727.