1 #include<stdio.h>
2 int rm[]={31,29,31,30,31,30,31,31,30,31,30,31};
3 int pm[]={31,28,31,30,31,30,31,31,30,31,30,31};
4 int isp(int year)
5 {
6 if((year%4==0&&year%100!=0)||year%400==0) return 1;
7
8 return 0;
9 }
10 int main()
11 {
12
13 int y,m,n,d,dd,day;
14 while(scanf("%d",&n)!=EOF)
15 {
16 if(n==-1)break;
17 y=2000,m=0,day=n;
18 while(n>=(isp(y)?366:365))
19 {
20 n=n-(isp(y)?366:365);
21 y++;
22 }
23 while(n>=(isp(y)?rm[m]:pm[m]))
24 {
25 n=n-(isp(y)?rm[m]:pm[m]);
26 m=(m+1)%12;
27 }
28 d=n%(isp(y)?rm[m]:pm[m])+1;
29 m=m+1;
30 printf("%d",y);
31 m<10?printf("-0%d",m):printf("-%d",m);
32 d<10?printf("-0%d",d):printf("-%d",d);
33 dd=day%7;
34 switch(dd)
35 {
36 case 0 : printf(" Saturday\n");break;
37 case 1 : printf(" Sunday\n");break;
38 case 2 : printf(" Monday\n");break;
39 case 3 : printf(" Tuesday\n");break;
40 case 4 : printf(" Wednesday\n");break;
41 case 5 : printf(" Thursday\n");break;
42 case 6 : printf(" Friday\n");break;
43 }
44
45
46 }
47 return 0;
48 }