提示: 欢迎访问OurACM平台。
Problem 1391 Finishing Date

Accept: 197    Submit: 381
Time Limit: 1000 mSec    Memory Limit : 32768 KB

Problem Description

In the problem, you will be given a starting date and the duration of an event. You need to find out the finishing date of the event.

There is a public misconception that a year is a leap year if it multiple of 4. This is not true. The truth is that, if the year is multiple of 400, it is a leap year. Otherwise, if the year is multiple of 100, it is not a leap year. Otherwise, if the year is multiple of 4, it is a leap year. Otherwise, it is not a leap year.

Examples:
1996 is a leap year. 1997 is a not leap year. 2000 is a leap year. 2100 is a not leap year. 2400 is a leap year.
(Actually, the REAL truth is even more complicated. But you can assume the above description of leap year is true for this problem. For those who want to know, you can visit: here after the contest.)

Input

The input file contains at most 250 lines of inputs. Each line contains four integer y, m, d, n, where y (2000 <= y < 4000) is the year, m is the month, d is the day and n (0 < n < 1000) is the duration in days of the event. You can safely assume that the input date is a valid date. Input is terminated by a line containing four zeros. This line should not be processed.

Output

For each input, print three integers y', m', d' in a single line where they are representing the year, month and day of the finishing date of the event.

Sample Input

2005 9 24 1 2005 12 31 2 2006 2 28 367 2007 2 28 367 0 0 0 0

Sample Output

2005 9 24 2006 1 1 2007 3 1 2008 2 29

Source

2005 HKUST Local Contest

Submit  Back  Status  Discuss