Problem hidden
This problem was hidden by Editorial Board member probably because it has incorrect language version or invalid test data, or description of the problem is not clear.

GREGCAL - Gregorian calendar

Given a date, your task is to print the weekday.

Notice: In Julian calendar leap years were years which were divisible by 4. According to Gregorian calendar, leap years are years which are divisible by 4 excluding these which are divisible by 100 and are not divisible by 400.

Input

The first line of the standard input contains one integer t (t<101) which is the number of test cases.

In each of the next t lines there is a date in format yyyy:mm:dd (1582<year<2010).

Output

For each test case print weekday (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday or Sunday) for given date or ERROR if the date is incorrect.

Example

Input:
2
1959:10:10
1962:02:29
Output:
Saturday
ERROR

Special thanks to Rafał Spręga for the concept of this task.


Added by:Piotr Ką…kol
Date:2009-12-25
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: NODEJS SCM qobi
Resource:Gregorian calendar

hide comments
2014-08-26 02:57:48 Piotr KÄ…kol
@Rajat Sharma - 2002:06:03
2014-08-22 19:17:32 its_time_to_code
checked many test cases still getting WA.
2011-10-09 09:53:35 HWK
@Jander: Why? There are many reasons: You're the best Perl shortener, you've got most of shortest solutions, you've beaten Zoltan and shinh,...
2011-10-08 18:35:08 Jander
@HWK: Why, thank you. Maybe I just need to get out more often, rather than devoting my time to these tasks :-)
2011-10-06 16:50:36 HWK
@Jander: Congratulations on the first SHORTEN rank. You're really deserving of it.
2011-04-29 10:18:08 anonymous
I thought that m>0 and d>0... Works now, thanks.
2011-04-28 21:37:43 Piotr KÄ…kol
Of course. :-)
There are the tests:
2004:00:23
2000:03:00
2011-04-28 14:42:52 anonymous
Piotr, could you please check why solution #5022761 fails? I checked every date from 1970 to now comparing it to UNIX' "date" tool, it works flawlessly.
2010-08-01 21:49:05 Piotr KÄ…kol
1600:02:29 - why You print for this test ERROR? 1600 is a leap year.
2010-08-01 19:40:34 HWK
At home solution 3879906 gives correct results for Python 2.4 and 2.6. Why not for 2.5? Isn't the locale-setting not english?
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.