Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Sofdar Ali's Next Day

By Kryptonyte · Limits 1.5s, 512 MB

Sofdor Ali goes to Karwan Bazar every Thursday to eat Jilapi! But he often forgets what day is Thursday! In fact, he struggles to figure out the exact date for any day. He has an alarm clock in his pocket and it only rings at a specific time of the day. But this old clock does not give him information about the date. Sofdor has come up with a solution to this problem. Whenever he needs to know what day it is, he buys a newspaper. Newspapers always have dates written in it, and that solves Sofdor’s problem. Well, at least for a day.

But buying newspapers is costly for Sofdor Ali, as he has to spend most of his money for buying important equipment for his experiment. So Sofdor is wondering, how he could reduce the cost of buying newspapers. Then he decided, he would buy a newspaper for one day and then calculate the next date from the newspaper’s date. That will reduce the cost of buying newspapers to half, as Sofdor only has to buy one newspaper in two days.

Now you have to write a program that will help Sofdor Ali to calculate the date of the next day, once the current date is given.

Input

The first line of the input is an integer T ( 1 ≤ T ≤ 1000000 ) denoting the number of test cases. Each of the next T lines describe 3 integers D ( 1 ≤ D ≤ 31 ), M ( 1 ≤ M ≤ 12 ) and Y ( 1900 ≤ Y ≤ 5000 ) which denotes day, month and year.

You can safely assume that every date that is given as an input is a valid date.

Output

For each date, print the next date in the following format:

Day Month, Year

Day must be formatted with a leading zero if it is less than 10.

Month will be in the following format:

{“Jan”,“Feb”,“Mar”,“Apr”,“May”,“Jun”,“Jul”,“Aug”,“Sep”,“Oct”,“Nov”,“Dec”};

See the sample input output for details.

Sample

InputOutput
4
1 1 1993
20 10 1999
15 5 2009
11 11 1993

02 Jan, 1993
21 Oct, 1999
16 May, 2009
12 Nov, 1993

Explanation

According to Wikipeida, a leap year can be calculated in the following way:

if (year is not exactly divisible by 4) then (it is a common year)

else if (year is not exactly divisible by 100) then (it is a leap year)

else if (year is not exactly divisible by 400) then (it is a common year)

else (it is a leap year)

Discussion

Statistics


53% Solution Ratio

Ashik1233Earliest, Dec '16

mdvirusFastest, 0.2s

the_belalLightest, 13 MB

Hasan_CZSShortest, 638B

Submit

Login to submit

Related Contests

DRMCSC Programming Contest 2016 Ended at 2016-02-06 08:50:00 +0000 UTC
Replay of DRMCSC Programming Contest 2016 Ended at 2016-02-21 15:00:00 +0000 UTC
SUST Intra University Programming Contest 2017 (Junior) Selection 3 Ended at 2017-07-23 12:45:00 +0000 UTC