Problem:


What day is today?

Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29.

Input

The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day. 

The number of datasets is less than or equal to 50.

Output

For each dataset, print the day (please see the following words) in a line.

Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday

Sample Input

1 1
2 29
0 0

Output for the Sample Input

Thursday
Sunday



Sample input:
1 1
2 29
0 0


Sample output:
Thursday
Sunday

Submission status: Accepted

Solution code:
from datetime import date
while True:
    m,d = map(int, input().split())
    if m == 0 or d == 0:
        break
    wDay = date(2004, m, d).weekday()
    if wDay == 0:
        print("Monday")
    elif wDay == 1:
        print("Tuesday")
    elif wDay == 2:
        print("Wednesday")
    elif wDay == 3:
        print("Thursday")
    elif wDay == 4:
        print("Friday")
    elif wDay == 5:
        print("Saturday")
    elif wDay == 6:
        print("Sunday")

Submission status: Accepted

Solution code:
from datetime import date

day = (
       'Monday',
       'Tuesday',
       'Wednesday',
       'Thursday',
       'Friday',
       'Saturday',
       'Sunday',
       'Sunday',)
while 1:
    m, d = list(map(int, input().split()))
    if m == 0:
        break
    print(day[date(2004, m, d).weekday()])

Submission status: Accepted

Solution code:

day = (
       'Sunday',
       'Monday',
       'Tuesday',
       'Wednesday',
       'Thursday',
       'Friday',
       'Saturday',
)
mm = {1:4,
      2:0,
      3:1,
      4:4,
      5:6,
      6:2,
      7:4,
      8:0,
      9:3,
      10:5,
      11:1,
      12:3,
      }
while 1:
    m, d = list(map(int, input().split()))
    if m == 0:
        break
    print(day[(mm[m] + d - 1)%7])

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
import datetime


def main(a, b):
    dt = datetime.datetime(2004, a, b)
    week_num = dt.weekday()

    if week_num == 0:
        print('Monday')
    elif week_num == 1:
        print('Tuesday')
    elif week_num == 2:
        print('Wednesday')
    elif week_num == 3:
        print('Thursday')
    elif week_num == 4:
        print('Friday')
    elif week_num == 5:
        print('Saturday')
    elif week_num == 6:
        print('Sunday')


while True:
    a, b = [int(e) for e in input().split()]
    if a == 0 and b == 0:
        break

    main(a, b)

Submission status: Accepted

Solution code:
mday = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
youbi = ["Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"]

while True:
	month, day = map(int, input().split())
	if month == day == 0: break

	days = 0
	for m in range(12):
		if month-1 <= m: break
		days += mday[m]
	days += day

	print(youbi[days % 7])

Submission status: Accepted

Solution code:
from datetime import date

weeks = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]

while True:

  s = map(int, raw_input().split())

  if s[0] == 0:
    break

  print weeks[date(2004, s[0], s[1]).weekday()]

Submission status: Accepted

Solution code:
days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
nums = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
while True:
    try:
        m, d = map(int, input().split())
        if not m:
            break
    except:
        break
    print(days[(sum(nums[:m - 1]) + d + 2) % 7])

Submission status: Accepted

Solution code:
c = []
m = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
w = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
s = 3
for d in m:
    c.append([(s + i) % 7 for i in xrange(d)])
    s = c[-1][-1] + 1
while 1:
    mon, day = map(int, raw_input().split())
    if mon == 0: break
    print w[c[mon - 1][day - 1]]

Submission status: Accepted

Solution code:
import sys
import datetime

w = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
while True:
    m, d = map(int, raw_input().split())
    if m == 0 and d == 0:
        break
    print w[datetime.date(2004,m,d).weekday()]

Submission status: Accepted

Solution code:
import datetime

daylist = ["Monday", "Tuesday", "Wednesday",
           "Thursday", "Friday", "Saturday", "Sunday"]

while True:
    m, d = map(int, input().split())
    if m == 0:
        break
    day = datetime.date(2004, m, d).weekday()
    print(daylist[day])

Submission status: Accepted

Solution code:
import math
def Wit(y,m,d):
    if m == 1 or m == 2:
        y -= 1
        m += 12
    e = math.floor((26 * (m + 1)) / 10)
    Y = y % 100
    C = math.floor(y / 100)
    f = math.floor(C / 4)
    g = math.floor(Y / 4)
    h = d + e + Y + f + g + 5 * C
    h = int(h % 7)
    return h
while True:

    y = 2004
    m,d = map(int,input().split())
    if m == 0 and d == 0:
        break
    You = Wit(y,m,d)
    if You == 1:
        print("Sunday")
    elif You == 3:
        print("Tuesday")
    elif You == 2:
        print("Monday")
    elif You == 4:
        print("Wednesday")
    elif You == 5:
        print("Thursday")
    elif You == 6:
        print("Friday")
    elif You == 0:
        print("Saturday")

Submission status: Accepted

Solution code:
from datetime import date

if __name__ == '__main__':
    while True:
        # ??????????????\???
        month, day = [int(x) for x in input().split(' ')]
        if month == 0:
            break

        # ?????\????¨??????¨???????????????
        dt = date(2004, month, day)
        print(dt.strftime('%A'))

Submission status: Accepted

Solution code:
from datetime import date

while True:
    m, d = map(int, input().split())
    if (m, d) == (0, 0):
        break
    weeks = {1:'Monday',2:'Tuesday',3:'Wednesday',4:'Thursday',5:'Friday',6:'Saturday',7:'Sunday'}
    w = date.isoweekday(date(2004, m, d))
    print(weeks[w])

Submission status: Accepted

Solution code:
from datetime import date
week=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]
while True:
    a,b=map(int,input().split())
    if a==0:
        break
    print(week[date(2004,a,b).weekday()])

Submission status: Accepted

Solution code:
from datetime import date
LIST=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]

while True:
    m, d = map(int,input().split())
    if m == 0:
        break
    print(LIST[date(2004,m,d).weekday()])

Submission status: Accepted

Solution code:
while 1:
    m,d=map(int,input().split())
    if m==0:break
    print(['Wednes', 'Thurs', 'Fri', 'Satur', 'Sun', 'Mon', 'Tues'][([0,31,60,91,121,152,182,213,244,274,305,335][m-1]+d)%7]+'day')

Submission status: Accepted

Solution code:
while 1:
    m,d=map(int,input().split())
    if m==0:break
    print(['Wednes','Thurs','Fri','Satur','Sun','Mon','Tues'][([0,31,60,91,121,152,182,213,244,274,305,335][m-1]+d)%7]+'day')

Submission status: Accepted

Solution code:
import datetime
while 1:
    m,d=map(int,input().split())
    if m==0:break
    print(['Mon','Tues','Wednes','Thurs','Fri','Satur','Sun'][datetime.date(2004,m,d).weekday()]+'day')

Submission status: Accepted

Solution code:
import datetime

l = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ]

while True:
  m, d = raw_input().rstrip().split(" ")
  if int(m) == 0 and int(d) == 0: break
  print(l[datetime.date(2004, int(m), int(d)).weekday()])

Submission status: Accepted

Solution code:
from datetime import date
import calendar

while True:
    m, d = map(int, input().split())
    if not m:
        break
    print(calendar.day_name[date(2004, m, d).weekday()])

Submission status: Accepted

Solution code:
month = [0,31,29,31,30,31,30,31,31,30,31,30,31]
week = ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']

while True:
    m,d = list(map(int,input().split()))
    if m == 0 and d == 0:
        break
    day = 3
    x = 1
    y = 1
    while x != m or y != d:
        if y == month [x]:
            x += 1
            y = 1
        else:
            y += 1
        day += 1
        day %= 7
    print(week [day])

Submission status: Accepted

Solution code:
days = [31,29,31,30,31,30,31,31,30,31,30,31]
ans = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]

while True:
    idx = 3
    m,d = map(int, input().split())
    if m==0: break
    print(ans[(idx+sum(days[:m-1])+d-1)%7])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import datetime

DAY_OF_WEEK = ['Thursday', 'Friday', 'Saturday', 'Sunday', 'Monday', 'Tuesday', 'Wednesday']
MONTH = [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

for s in sys.stdin:
    month, day = map(int, s.split())
    if month == day == 0:
        break

    past_day = sum(MONTH[:month]) + day - 1

    a = past_day % 7
    print(DAY_OF_WEEK[a])

Submission status: Accepted

Solution code:
from datetime import date
DOTW = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
while True :
    try :
        month,day = [int(_) for _ in input().split()]
        print(DOTW[date(2004,month,day).weekday()])
    except : break

Submission status: Accepted

Solution code:
monthday = [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
days = ['Wednesday', 'Thursday', 'Friday', 'Saturday',
		'Sunday', 'Monday', 'Tuesday']

def nthday(m, d):
	cnt = d
	for i in range(0, m):
		cnt += monthday[i]
	return cnt

while True:
	inpt = map(int, raw_input().split())
	if inpt[0] == 0:
		break
	else:
		print days[nthday(inpt[0], inpt[1]) % 7]

Submission status: Accepted

Solution code:
import sys
from datetime import *
for line in sys.stdin:
    m, d = map(int,line.split())
    try:
        print(date(2004, m, d).strftime("%A"))
    except ValueError:
        break

Submission status: Accepted

Solution code:
import datetime
 
days = [
    'Monday',
    'Tuesday',
    'Wednesday',
    'Thursday',
    'Friday',
    'Saturday',
    'Sunday'
        ]
 
while True:
    m, d = map(int, input().split(' '))
    if m == 0: break
    print(days[datetime.date(2004, m, d).weekday()])

Submission status: Accepted

Solution code:
from datetime import date
while True:
    m, d = map(int, input().split())
    if m == 0:
        break
    result = date(2004, m, d).isoweekday()
    print("Monday"*(result==1)+"Tuesday"*(result==2)+"Wednesday"*(result==3)+"Thursday"*(result==4)+"Friday"*(result==5)+"Saturday"*(result==6)+"Sunday"*(result==7))

Submission status: Accepted

Solution code:
from datetime import date
while True:
    m, d = map(int, input().split())
    if m == 0:
        break
    result = date(2004, m, d).isoweekday()
    print("Mon"*(result==1)+"Tues"*(result==2)+"Wednes"*(result==3)+"Thurs"*(result==4)+"Fri"*(result==5)+"Satur"*(result==6)+"Sun"*(result==7)+"day")

Submission status: Accepted

Solution code:
week = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
days = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
while 1:
    key = 2
    data = list(map(int, input().split()))
    if data[0] == 0 and data[1] == 0:
        break
    month = data[0]
    day = data[1]
    for i in range(month-1):
        key += days[i]
    key += day
    print(week[key % 7])

Submission status: Accepted

Solution code:
# Aizu Problem 0027: What day is today?
#
import sys, math, os, datetime

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


DAY = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
while True:
    m, d = [int(_) for _ in input().split()]
    if m == d == 0:
        break
    print(DAY[datetime.date(2004, m, d).weekday()])

Submission status: Accepted

Solution code:
import sys
from datetime import *
from time import *


day = [ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ]

while True:
    try:
        user_input_date = '2004/'+'/'.join(input().split())
        if user_input_date == '2004/0/0':
            break
        else:
            a = datetime.strptime(user_input_date,'%Y/%m/%d')
            print(day[a.weekday()])
    except ValueError:
        pass
else:
    sys.exit(1)

Submission status: Accepted

Solution code:
import sys
from datetime import *
from time import *

day = [ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ]

while True:
    try:
        user_input_date = '2004/'+'/'.join(input().split())
        if user_input_date == '2004/0/0':
            break
        else:
            a = datetime.strptime(user_input_date,'%Y/%m/%d')
            print(day[a.weekday()])
    except ValueError:
        pass
else:
    sys.exit(1)

Submission status: Accepted

Solution code:
import sys
from datetime import *
from time import *

day = [ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ]

while True:
    try:
        user_input_date = '2004/'+'/'.join(raw_input().split())
        if user_input_date == '2004/0/0':
            break
        else:
            a = datetime.strptime(user_input_date,'%Y/%m/%d')
            print day[a.weekday()]
    except ValueError:
        pass
else:
    sys.exit(1)

Submission status: Accepted

Solution code:
day = ['Wednesday','Thursday', 'Friday', 'Saturday', 'Sunday', 'Monday', 'Tuesday', 'Wednesday']
month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]


m, d = [int(i) for i in input().split()]
while m != 0:
    sum = 0
    for i in range(0, m - 1):
        sum += month[i]
    sum += d
    print(day[sum % 7])
    m, d = [int(i) for i in input().split()]

Submission status: Accepted

Solution code:
# 0027
import datetime
day = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
while True :
    month, date = map(int, input().split())
    if month == date == 0: break
    print(day[datetime.date(2004, month, date).weekday()])

Submission status: Accepted

Solution code:
days_in_month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
day = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']

while True:
    m, d = map(int, input().split())
    if m == 0 or d == 0:
        break
    days = 0
    for month in range(0, m-1):
        days += days_in_month[month]
    days += d + 2
    days %= 7
    print(day[days])

Submission status: Accepted

Solution code:
month, day = map(int, raw_input().split())
days = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
youbi = ["Sunday", "Monday", "Tuesday",
         "Wednesday", "Thursday", "Friday", "Saturday"]
while month != 0:
    Days = 0
    for i in range(month - 1):
        Days += days[i]
    Days += day
    print youbi[(Days + 3) % 7]
    month, day = map(int, raw_input().split())

Submission status: Accepted

Solution code:
lis=[0 for i in range(7)]
lis[0]="Wednesday"
lis[1]="Thursday"
lis[2]="Friday"
lis[3]="Saturday"
lis[4]="Sunday"
lis[5]="Monday"
lis[6]="Tuesday"
while 1:
    date=0
    x,y=map(int,input().split())
    if x!=0 and y!=0:
        for i in range(1,x):
            if i==4 or i==6 or i==9 or i==11:
                date=date+30
            elif i==2:
                date =date+29
            else:
                date=date+31
        k=(date+y)%7
        print(lis[k])
    else:
        break

Submission status: Accepted

Solution code:
f = lambda x:x%7
p = print

def judge(x):
    if  f(x)== 1:
        p("Thursday")
    elif f(x) == 2:
        p("Friday")
    elif f(x) == 3:
        p("Saturday")
    elif f(x) == 4:
        p("Sunday")
    elif f(x) == 5:
        p("Monday")
    elif f(x) == 6:
        p("Tuesday")
    else:
        p("Wednesday")

days = [31,29,31,30,31,30,31,31,30,31,30,31]
while True:
    month,day = [int(i) for i in input().split()]
    if month == 0:
        break
    elif month == 1:   
        x = day
    else:
        x = sum(days[:month-1]) + day
    judge(x)

Submission status: Accepted

Solution code:
import sys

DoD = ["Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"]


def getPNoD(n):
  if n == 1:
    return 0
  elif n == 3:
    return 29 + getPNoD(n-1)
  elif (n % 2 == 0 and n <= 8) or (n % 2 != 0 and n > 8):
    return 31 + getPNoD(n-1)
  else:
    return 30 + getPNoD(n-1)


for line in sys.stdin:
  m, d = [int(i) for i in line.split()]
  if m == 0:
    break
  n = getPNoD(m) + d - 1
  print(DoD[n % 7])

Submission status: Accepted

Solution code:
import datetime

weekdays = [
    'Monday',
    'Tuesday',
    'Wednesday',
    'Thursday',
    'Friday',
    'Saturday',
    'Sunday'
]

while True:
    m,d = [int(i) for i in input().split()]
    if not(m or d):
        break
    print(weekdays[datetime.date(2004, m, d).weekday()])

Submission status: Accepted

Solution code:
import datetime

date_list = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]

while True:
    m, d = map(int, input().split())
    if m == 0 and d == 0:
        break
    print(date_list[datetime.date(2004, m, d).weekday()])

Submission status: Accepted

Solution code:
accum = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335]
youbi = ["Wednesday", "Thursday", "Friday", "Saturday",
         "Sunday", "Monday", "Tuesday", ]


def getYoubi(month, day):
    total = accum[month - 1] + day
    return youbi[total % 7]


month = 13
day = 32

while True:
    month, day = map(int, input().split())
    if month == 0:
        break
    print(getYoubi(month, day))

Submission status: Accepted

Solution code:
while True:
    a,b=map(int,input().split())
    c=0
    if a==0:
        break
    tuki=[31,29,31,30,31,30,31,31,30,31,30,31]
    a-=1
    for i in range(a):
        c=c+tuki[i]
    c+=b
    if c%7==1:
        ans="Thursday"
    if c%7==2:
        ans="Friday"
    if c%7==3:
        ans="Saturday"
    if c%7==4:
        ans="Sunday"
    if c%7==5:
        ans="Monday"
    if c%7==6:
        ans="Tuesday"
    if c%7==0:
        ans="Wednesday"
    print(ans)

Submission status: Accepted

Solution code:
month=[31,29,31,30,31,30,31,31,30,31,30,31]
week =['Wednesday','Thursday','Friday','Saturday','Sunday','Monday','Tuesday']

while True:
    sum=0
    m,d=map(int,raw_input().split())
    if m==0 and d==0:
        break
    else:
        for i in range(m-1):
            sum += month[i]
        sum += d
        flag = sum % 7
        print week[flag]

Submission status: Accepted

Solution code:
import datetime
for e in iter(input,'0 0'):print(['Mon','Tues','Wednes','Thurs','Fri','Satur','Sun'][datetime.date(2004,*map(int,e.split())).weekday()]+'day')

Submission status: Accepted

Solution code:
for e in iter(input,'0 0'):
 m,d=map(int,e.split())
 print(['Wednes','Thurs','Fri','Satur','Sun','Mon','Tues'][([0,31,60,91,121,152,182,213,244,274,305,335][m-1]+d)%7]+'day')

Submission status: Accepted

Solution code:
import datetime
for e in iter(input,'0 0'):print(datetime.date(2004,*map(int,e.split())).strftime("%A"))

Submission status: Accepted

Solution code:
from datetime import *
for e in iter(input,'0 0'):print(date(2004,*map(int,e.split())).strftime("%A"))

Submission status: Accepted

Solution code:
from datetime import *
for e in iter(input,'0 0'):print(date(2004,*map(int,e.split())).strftime('%A'))

Submission status: Accepted

Solution code:
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

daylist = [31,29,31,30,31,30,31,31,30,31,30,31]
namelist = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]

N = list(get_input())
m,d = [int(i) for i in N[0].split()]
cnt = 1
while m != 0 or d != 0:
    ans = 2
    for i in range(m-1):
        ans += daylist[i]
    ans += d
    ans %= 7
    print(namelist[ans])

    m,d = [int(i) for i in N[cnt].split()]
    cnt += 1

Submission status: Accepted

Solution code:
# coding=utf-8
day_1_list = [4, 7, 1, 4, 6, 2, 4, 7, 3, 5, 1, 3]

while True:
    month, day = map(int, input().split())
    if month == 0:
        break
    dw = (day_1_list[month-1] + day - 1) % 7
    if dw == 1:
        print("Monday")
    elif dw == 2:
        print("Tuesday")
    elif dw == 3:
        print("Wednesday")
    elif dw == 4:
        print("Thursday")
    elif dw == 5:
        print("Friday")
    elif dw == 6:
        print("Saturday")
    elif dw == 0:
        print("Sunday")

Submission status: Accepted

Solution code:
while 1:
	day = ['Wednes','Thurs','Fri','Satur','Sun','Mon','Tues']
	month = [0,31,60,91,121,152,182,213,244,274,305,335]
	m,d=map(int,input().split())
	if m == 0:
		break
	print(day[(month[m-1]+d)%7]+'day')

Submission status: Accepted

Solution code:
from datetime import datetime

youbi = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']

while True:
    line = input()
    if line.strip() == '0 0':
        break
    else:
        month, day = map(int, line.strip().split(' '))
        f = '%Y-%m-%d'
        a = datetime.strptime('2004-{}-{}'.format(month, day), f)
        print(youbi[a.weekday()])

Submission status: Accepted

Solution code:
s = (0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30)
w = ("Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday")
while True:
    m, d = map(int, input().split())
    if m == 0:break
    print(w[(d + sum(s[:m])) % 7])

Submission status: Accepted

Solution code:
from datetime import datetime

y = 2004

while (True):
    m, d = map(int, input().split())
    if m == 0: break

    day = datetime(y, m, d)
    print(day.strftime('%A'))

Submission status: Accepted

Solution code:
from datetime import datetime
r=[]
while 1:
    l=list(map(int,input().split()))
    if not l[0] and not l[1]:break
    r.extend([datetime(year=2004,month=l[0],day=l[1]).weekday()])
for i in r:
    if i==0:print("Monday")
    elif i==1:print("Tuesday")
    elif i==2:print("Wednesday")
    elif i==3:print("Thursday")
    elif i==4:print("Friday")
    elif i==5:print("Saturday")
    elif i==6:print("Sunday")

Submission status: Accepted

Solution code:
from datetime import date

dic = {0:"Monday", 1:"Tuesday", 2:"Wednesday", 3:"Thursday", 4:"Friday", 5:"Saturday", 6:"Sunday"}

while True:
  month, day = map(int, input().split())
  
  if not month:
    break

  print(dic[date(2004, month, day).weekday()])

Submission status: Accepted

Solution code:
# AOJ 0027 What day is today?
# Python3 2018.6.11 bal4u

def Zeller(y, m, d):
    if m == 1 or  m == 2:
        y -= 1
        m += 12
    return (y + y//4 - y//100 + y//400 + (13*m + 8)//5 + d) % 7

import sys
week = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
for line in sys.stdin:
    m, d = list(map(int, line.split()))
    if m >= 1:
        print(week[Zeller(2004, m, d)])
    else:
        break

Submission status: Accepted

Solution code:
def day(Y, m, d, Gregorian=True):
    from math import floor

    # ツェラーの公式
    if m <= 2:
        Y -= 1
        m += 12
    y = Y%100
    c = Y//100
    g = 5*c+floor(c/4) if Gregorian else 5-c
    return (d + floor(26*(m+1)/10) + y + floor(y/4) +  g) %7 # 0->土曜, 6->金曜

day_en = ["Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"]

while True:
    m, d = map(int, input().split())
    if m == 0:
        break
    print(day_en[day(2004, m, d)])

Submission status: Accepted

Solution code:
import sys

dictionary = {
        0:0,
        1:31,
        2:60,
        3:91,
        4:121,
        5:152,
        6:182,
        7:213,
        8:244,
        9:274,
        10:305,
        11:335,
        12:366}

for line in sys.stdin.readlines():
    line = line.strip()
    month, day = map(int, line.split())
    if month == 0:
        break
    else:
        pastDay = dictionary[month - 1] + day - 1
        if pastDay % 7 == 0:
            print "Thursday"
        elif pastDay % 7 == 1:
            print "Friday"
        elif pastDay % 7 == 2:
            print "Saturday"
        elif pastDay % 7 == 3:
            print "Sunday"
        elif pastDay % 7 == 4:
            print "Monday"
        elif pastDay % 7 == 5:
            print "Tuesday"
        else:
            print "Wednesday"

Submission status: Accepted

Solution code:

dates = []
youbi = []

for i in range(1,13):
    if i == 1 or i == 3 or i == 5 or i == 7 or i == 8 or i == 10 or i == 12:
        for j in range(1,32):
            dates.append([i,j])
    elif i == 4 or i == 6 or i == 9 or i == 11:
        for j in range(1,31):
            dates.append([i,j])
    elif i == 2:
        for j in range(1,30):
            dates.append([i,j])

while True:
    x = map(int, raw_input().split(' '))
    if x == [0,0]:
        for yo in youbi:
            print yo
        break
    elif dates.index(x) % 7 == 0:
        youbi.append('Thursday')
    elif dates.index(x) % 7 == 1:
        youbi.append('Friday')
    elif dates.index(x) % 7 == 2:
        youbi.append('Saturday')
    elif dates.index(x) % 7 == 3:
        youbi.append('Sunday')
    elif dates.index(x) % 7 == 4:
        youbi.append('Monday')
    elif dates.index(x) % 7 == 5:
        youbi.append('Tuesday')
    elif dates.index(x) % 7 == 6:
        youbi.append('Wednesday')

Submission status: Accepted

Solution code:
import calendar
week={0:"Monday",
      1:"Tuesday",
      2:"Wednesday",
      3:"Thursday",
      4:"Friday",
      5:"Saturday",
      6:"Sunday"}
while True:
    month,day=map(int,raw_input().split())
    if month==0:break
    print week[calendar.weekday(2004,month,day)]

Submission status: Accepted

Solution code:
import calendar
while True:
    month,day=map(int,raw_input().split())
    if month==0:break
    print calendar.day_name[calendar.weekday(2004,month,day)]

Submission status: Accepted

Solution code:
day = ["Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"]
month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
while True:
	m, d = map(int, raw_input().split())
	if m == d == 0: break
	print day[(sum(month[0:m-1]) + d - 1) % 7]

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

import sys
import datetime

"""
Input
    複数のデータセットを処理しなければなりません。
    １つのデータセットに月と日が１つのスペース区切られて１行に与えられます。
    月が 0 となったとき入力の最後とします
    （この場合は処理をしないでプログラムを終了させる）。

Output
    各データセットごとに曜日を英語で１行に出力して下さい。
    以下の訳を参考にして出力して下さい。

    Monday
    Tuesday
    Wednesday
    Thursday
    Friday
    Saturday
    Sunday
"""


def get_weekday(month, day):
    weekdays = ("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")
    return weekdays[datetime.date(2004, month, day).weekday()]


def main():
    while 1:
        s = sys.stdin.readline()
        month, day = [int(x) for x in s.split(" ")]
        if month == 0:
            return
        print get_weekday(month, day)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import datetime
week = ["Monday", "Tuesday", "Wednesday", "Thursday",
        "Friday", "Saturday", "Sunday"]
while True:
    (m, d) = [int(i) for i in raw_input().split()]
    if m == 0:
        break
    dt = datetime.datetime(2004, m, d)
    print week[dt.weekday()]

Submission status: Accepted

Solution code:
ans=[]
week=[
      'Monday',         #0
      'Tuesday',        #1
      'Wednesday',      #2
      'Thursday',       #3
      'Friday',         #4
      'Saturday',       #5
      'Sunday'          #6
      ]
year=[
      2, 5, 6, 2, 4, 0, 2, 5, 1, 3, 6, 1
      ]
while True:
    month,day=map(int,raw_input().split())
    if month==0 and day==0:
        break
    ans.append(week[ (year[month-1] + day) %7])
    
for i in ans:
    print i

Submission status: Accepted

Solution code:
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
from sys import stdin
from datetime import date

for line in stdin:
    if line.startswith('0 0'):
        break
    print(date(2004, *(int(s) for s in line.split())).strftime('%A'))

Submission status: Accepted

Solution code:
import datetime
while True:
	x = map(int,raw_input().split(' '))
	if x[0] != 0:
		day = datetime.date(2004,x[0],x[1])
		weekday = day.isoweekday()
		if weekday == 1:
			print 'Monday'
		if weekday == 2:
			print 'Tuesday'
		if weekday == 3:
			print 'Wednesday'
		if weekday == 4:
			print 'Thursday'
		if weekday == 5:
			print 'Friday'
		if weekday == 6:
			print 'Saturday'
		if weekday == 7:
			print 'Sunday'
		continue
	else:
		break

Submission status: Accepted

Solution code:
import datetime
week=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]
while 1:
    month,day=map(int,raw_input().split())
    if month==0:break;
    print week[datetime.datetime(2004,month,day).weekday()]

Submission status: Accepted

Solution code:
a=['Wednesday','Thursday','Friday','Saturday','Sunday','Monday','Tuesday',0]
while True:
    q=map(int,raw_input().split())
    if sum(q) == 0: break
    print a[(sum([0,31,29,31,30,31,30,31,31,30,31,30,31][:q[0]])+q[1])%7]

Submission status: Accepted

Solution code:
while True:
    q=map(int,raw_input().split())
    if sum(q) == 0: break
    print ['Wednesday','Thursday','Friday','Saturday','Sunday','Monday','Tuesday',0][(sum([0,31,29,31,30,31,30,31,31,30,31,30,31][:q[0]])+q[1])%7]

Submission status: Accepted

Solution code:

import sys
from datetime import datetime


y = 2004

#input_file = open(sys.argv[1], 'r')

for line in sys.stdin:
    (m, d) = tuple(map(int, line.split(' ')))
    if m == 0:
        break
    date = datetime(y, m, d)
    print date.strftime("%A")

Submission status: Accepted

Solution code:
nm = [0,31,29,31,30,31,30,31,31,30,31,30]
while True:

    m,d = map(int,raw_input().split(" "))

    if m == 0:
        break
    else:
        nd = 0
        for i in range(m):
           nd += nm[i]

        nd += d
        n = nd%7
        if n == 1:
            print "Thursday"
        elif n == 2:
            print "Friday"
        elif n == 3:
            print "Saturday"
        elif n == 4:
            print "Sunday"
        elif n == 5:
            print "Monday"
        elif n == 6:
            print "Tuesday"
        else:                                                                                                                                                                                                
            print "Wednesday"

Submission status: Accepted

Solution code:
weekday=["Monday", "Tuesday", "Wednesday", "Thursday",
         "Friday", "Saturday", "Sunday"]

def monthday(month):
    if month in [1,3,5,7,8,10,12]: return 31
    elif month in [4,6,9,11]: return 30
    else: return 29

def days(month, day):
    return sum([monthday(i) for  i in range(1, month)]) + day
   
while True:
    m, d = map(int, raw_input().split())
    if m==0: break
    diff = days(m,d)-1
    print weekday[(diff +3)% 7]

Submission status: Accepted

Solution code:
import datetime

w = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']

while True:
    m,d = map(int, raw_input().split())
    if m == 0:
        break
    print w[datetime.date(2004, m, d).weekday()]

Submission status: Accepted

Solution code:
import datetime
import sys

weekdays = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']

for line in sys.stdin:
    data = line.strip().split()
    m = data[0]
    d = data[1]
    if m == '0':
        break

    date = datetime.datetime.strptime('2004-' + m + '-' + d + ' 13:13:13', '%Y-%m-%d %H:%M:%S')
    print weekdays[date.weekday()]