#include <stdio.h>
main() {
int a,b,c;
int m,n,x,y;
loop:
scanf("%d %d %d",&a,&b,&c);
if(b>12||c>31||a<=0||b<=0||c<=0) {
printf("日期输入错误\n");
goto loop;
}
else
{ x=(a-1)/4-(a-1)/100+(a-1)/400;
if (a%400==0||a%4==0&&a%100!=0)
{ switch(b) {
case 1:
m=c;
break;
case 2:
if(c>29) {
printf("日期输入错误\n");
goto loop;
}
else
{ m=31+c;
break;
}
case 3:
m=60+c;
break;
case 4:
if(c>30) {
printf("日期输入错误\n");
goto loop;
}
else
{ m=91+c;
break;
}
case 5:
m=121+c;
break;
case 6:
if(c>30) {
printf("日期输入错误\n");
goto loop;
}
else
{
m=152+c;
break;
}
case 7:
m=182+c;
break;
case 8:
m=213+c;
break;
case 9:
if(c>30) {
printf("日期输入错误\n");
goto loop;
}
else
{
m=244+c;
break;
}
case 10:
m=274+c;
break;
case 11:
if(c>30) {
printf("日期输入错误\n");
goto loop;
}
else
{
m=305+c;
break;
}
case 12:
m=335+c;
break;
default:
break;
}
n=(a-1)*365+x+m;
y=n%7;
if(y==0)
{
printf("星期日\n");
}
else {
printf("星期%d\n",y);
}
}
else
{ switch(b) {
case 1:
m=c;
break;
case 2:
if(c>28) {
printf("日期输入错误\n");
goto loop;
}
else
{
m=31+c;
break;
}
case 3:
m=59+c;
break;
case 4:
if(c>30) {
printf("日期输入错误\n");
goto loop;
}
else
{
m=90+c;
break;
}
case 5:
m=120+c;
break;
case 6:
if(c>30) {
printf("日期输入错误\n");
goto loop;
}
else
{
m=151+c;
break;
}
case 7:
m=181+c;
break;
case 8:
m=212+c;
break;
case 9:
if(c>30) {
printf("日期输入错误\n");
goto loop;
}
else
{
m=243+c;
break;
}
case 10:
m=273+c;
break;
case 11:
if(c>30) {
printf("日期输入错误\n");
goto loop;
}
else
{
m=304+c;
break;
}
case 12:
m=334+c;
break;
default:
break;
}
n=(a-1)*365+x+m;
y=n%7;
if(y==0)
{
printf("星期日\n");
}
else {
printf("星期%d\n",y);
}
}
}
goto loop;
}