Shinya saw a TV program called "Mayan Prophecy: The World Will End in 2012? In the end, he didn't know whether the world would end or not, but he was interested in the Mayan "Long Term Calendar" that was introduced in the program. In the program, the following explanation was given.
The Mayan long-term calendar is a very long calendar, consisting of 13 baktuns (1,872,000 days) in all, with units as shown in the table on the right. According to some calculations, the calendar is supposed to begin on August 11, 3114 BC and end on December 21, 2012, which has led some to believe that the world will end on December 21 this year. However, there is also the idea that 13 baktuns is one cycle, and that we will just start a new cycle when the current calendar ends. |
1 kin = 1 day 1 winal = 20 kins 1 tun = 18 winals 1 katun = 20 tun 1 baktun = 20 katun |
"What is the date of my twentieth birthday in the Mayan calendar?" Shinya wanted to try to represent various days in the Mayan long-term calendar.
Now, please create a program to convert between the Western calendar and the Mayan long-term calendar for Shinya.
The input consists of multiple data sets. The end of the input is indicated by a single line containing a character #. Each data set is given in the following format.
b.ka.t.w.ki
or
y.m.d
The dataset consists of one line containing one string, where b.ka.t.w.ki is the date in the Mayan long-term calendar, and y.m.d is the date in the Western calendar. The units given are as follows.
Mayan Calendarb | baktun | (0 ≤ b< 13) |
ka | katun | (0 ≤ ka < 20) |
t | tun | (0 ≤ t< 20) |
w | winal | (0 ≤ w < 18) |
ki | kin | (0 ≤ ki < 20) |
y | year | (2012 ≤ y ≤ 10,000,000) |
m | month | (1 ≤ m ≤ 12) |
d | day | (1 ≤ d ≤ 31) |
The maximum value of a day in the Western calendar depends on whether it is a large month, a small month, or a leap year (a leap year is a year in multiples of 4 that is not divisible by 100 or divisible by 400). The range of dates in the Mayan calendar is from 0.0.0.0.0 to 12.19.19.17.19. However, 0.0.0.0.0 of the Mayan long-term calendar corresponds to 2012.12.21 of the Western calendar. The range of dates in the Western calendar shall be from 2012.12.21 to 10000000.12.31.
The number of datasets should not exceed 500.
When the input is a Western calendar, the Mayan long-term calendar should be output in the same format as the input, and when the input is a Mayan long-term calendar, the Western calendar should be output in the same format as the input. Even if the conversion of the input Western calendar results in the next cycle of the Mayan long-term calendar, it may be output in the format b.ka.t.w.ki.
2012.12.31 2.12.16.14.14 7138.5.13 10.5.2.1.5 10000000.12.31 #
0.0.0.0.10 3054.8.15 0.0.0.0.10 6056.2.29 8.19.3.13.2