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
for i in range(year):
if i%400==0 or (i%4==0 and i%100!=0 ):
days+=366
else:
days+=365
for k in range(1,month):
days+=m_day[k]
if k==2 and (year%400==0 or (year%4==0 and year%100!=0 )):
days+=1
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 month<1 or month>12 or day <1 :
print("Illegal")
elif day>m_day[month]:
if (year%400 or (year%4==0 and year%100!=0)) and month==2 and day==29:
total_days=ymd(year,month,day)
print(total_days)
w=(total_days-t_days)%7
print(weekday[w])
else:
print("Illegal")
else:
total_days=ymd(year,month,day)
print(total_days)
w=(total_days-t_days)%7
print(weekday[w])