weekday=["Sunday","Monday","Tuesday","Wednesday","Thursday", "Friday","Saturday"]
def ymd(year,month,day):
m_day=[0,31,28,31,30,31,30,31,31,30,31,30,31]
days=0
year=abs(year)
for i in range(0,year):
if i%400==0 or (i%4==0 and i%100!=0 ):
days+=366
else:
days+=365
if (year%400==0 or (year%4==0 and year%100!=0 )):
m_day[2]=29
for k in range(1,month):
days+=m_day[k]
return days+day
m_day=[0,31,28,31,30,31,30,31,31,30,31,30,31]
t_days=ymd(2020,11,18)
print(t_days)
year,month,day=map(int,input().split())
if (year%400==0 or (year%4==0 and year%100!=0 )): #如果闰年2月为29天
m_day[2]=29
if month<1 or month>12 or day <1 :
print("Illegal")
elif day>m_day[month]:
print("Illegal")
else:
total_days=ymd(year,month,day)
print(total_days)
w=(total_days-t_days)%7
print(w,weekday[w-4])