eolymp
bolt
Try our new interface for solving problems
Problems

Age of Retirement

Age of Retirement

In some country it is decided to start raising the retirement age since January \textbf{1}^st \textbf{2012}. Prior to that date, the retirement age was \textbf{60} years. The raising of the retirement age is carried out as follows. The increase is repeated \textbf{K} times in total. Each time, the retirement age is increased by \textbf{M} months. The first increase occurs on January \textbf{1}^st \textbf{2012}, and each of the next (\textbf{K-1}) increases happens \textbf{N} months after the previous increase (\textbf{N} > \textbf{M}). For example, let \textbf{M=3}. Then citizens born on December \textbf{31}^st \textbf{1951} will retire on December \textbf{31}^st \textbf{2011}; and citizens born on January \textbf{1}^st \textbf{1952} will retire on April \textbf{1}^st \textbf{2012}. The date of retirement for a particular person is the minimum possible date on which that person's age is not less than the retirement age approved on that date. To determine when a citizen turns \textbf{I} years and \textbf{J} months, you need to add \textbf{I} years and \textbf{J} months to the date of his birth, leaving the day of the month the same. In case there is no such day in the calendar, the required date is the first day of the next month. Thus, given that \textbf{M=3} and \textbf{N=5} those born on January \textbf{31}^st \textbf{1952} will retire on May \textbf{1}^st \textbf{2012} as well as those born on February \textbf{1}^st \textbf{1952}. It is required to determine the date of citizen retirement given the date of his birth. It is considered that life expectancy can be arbitrarily large. A year is leap if the number of the year is divisible by \textbf{400} or it is divisible by \textbf{4} but is not divisible by \textbf{100}. \InputFile Three integers \textbf{M}, \textbf{N} and \textbf{K} (\textbf{0} < \textbf{M} ≤ \textbf{12}, \textbf{M} < \textbf{N} ≤ \textbf{24}, \textbf{0} ≤ \textbf{K} ≤ \textbf{60}) are given on the first line of input. The second line of input contains a citizen birth date in the format "\textbf{DD.MM.YYYY}" (that is, day, month and year without the quotes and with leading zero for numbers below \textbf{10}). All dates are between \textbf{01.01.1900} and \textbf{31.12.2100}. \OutputFile Print the date of retirement for the given citizen in the same format as input date.
Time limit 1 second
Memory limit 64 MiB
Input example #1
3 6 20
01.01.1952
Output example #1
01.04.2012