Calendar

A calendar is a system for measuring time, from hours and minutes, to months and days, and finally to years and centuries. The terms of hour, day, month, year and century are all units of time measurements of a calender system.

According to the Gregorian calendar, which is the civil calendar in use today, years evenly divisible by 4 are leap years, with the exception of centurial years that are not evenly divisible by 400. Therefore, the years 1700, 1800, 1900 and 2100 are not leap years, but 1600, 2000, and 2400 are leap years.

Given the number of days that have elapsed since January 1, 2000 A.D, your mission is to find the date and the day of the week.

Input

The input consists of lines each containing a positive integer, which is the number of days that have elapsed since January 1, 2000 A.D. The last line contains an integer -1, which should not be processed. You may assume that the resulting date won't be after the year 9999.

Output

For each test case, output one line containing the date and the day of the week in the format of "YYYY-MM-DD DayOfWeek", where "DayOfWeek" must be one of "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" and "Saturday".

Sample Input

1730
1740
1750
1751
-1

Sample Output

2004-09-26 Sunday
2004-10-06 Wednesday
2004-10-16 Saturday
2004-10-17 Sunday

http://blog.csdn.net/ydxzmhy/article/details/37883959

日历是一种用于测量时间,从几分钟到几个月和几天,最后几年和几个世纪的系统。小时,日,月,年,月的条件是日历系统的时间测量单位。
根据今天使用的民主日历的公历,除了4岁以下的年份,除了百分之百不能被400除以百分之几的年份外,所以1700年,1800年,1900年和2100年是不是闰年,而是1600年,2000年和2400年是闰年。
鉴于自2000年1月1日以来已经过去的天数,你的任务是找到日期和星期几。
输入
输入由包含正整数的行组成,这是自2000年1月1日以来经过的天数A.D.最后一行包含一个整数-1,不应该被处理。您可以假定所产生的日期不会在9999之后。
输出
对于每个测试用例,以“YYYY-MM-DD DayOfWeek”的格式输出包含日期和星期几的一行,其中“DayOfWeek”必须是“星期日”,“星期一”,“星期二”之一, “星期三”,“星期四”,“星期五”和“星期六”。