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: Wrong Answer

Solution code:
import datetime

print datetime.datetime.now()

Submission status: Wrong Answer

Solution code:
days=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']
dom=[31,29,31,30,31,60,31,31,30,31,30,31]
while True:
    try:
        (m,d)=map(int,raw_input().split())
        if m==0 and d==0: break
        day=4-1
        for i in xrange(m-1):
            day+=dom[i]
        day+=d
        print days[day%7]
    except EOFError: break

Submission status: Wrong Answer

Solution code:
days=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']
dom=[31,29,31,30,31,60,31,31,30,31,30,31]
while True:
    try:
        try:
            (m,d)=map(int,raw_input().split())
        except: break
        if m==0 and d==0: break
        day=4-1
        for i in xrange(m-1):
            day+=dom[i]
        day+=d
        print days[day%7]
    except EOFError: break

Submission status: Wrong Answer

Solution code:

import sys
import math

dayy = [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

def days(a, day):
    if a == 0:
        return day
    else:
        return days(a-1, day + dayy[a])


while 1:
    inp = raw_input().split()
    ii = int(inp[0])
    jj = int(inp[1])
    if ii == 0 and jj== 0:
        break
    ans = days(ii-1, 0) + jj
    print ans
    ans = ans % 7
    if ans == 1:
        print "Thursday"
        continue
    if ans == 2:
        print "Friday"
        continue
    if ans == 3:
        print "Saturday"
        continue
    if ans == 4:
        print "Sunday"
        continue
    if ans == 5:
        print "Monday"
        continue
    if ans == 6:
        print "Tuesday"
        continue
    if ans == 0:
        print "Wedneday"
        continue

Submission status: Wrong Answer

Solution code:
from datetime import date
import sys
for line in sys.stdin.readlines():
   m , d = map(int,line.split())
   if m != 0 and d != 0 :
       val = date(2004,m,d)
       day = val.isoweekday()
       if day == 0:
           print("Sunday")
       elif day == 1:
           print("Monday")
       elif day == 2:
           print("Tuesday")
       elif day == 3:
           print("Wednesday")
       elif day == 4:
           print("Thursday")
       elif day == 5:
           print("Friday")
       else:
           print("Saturday")
   else:
       break

Submission status: Wrong Answer

Solution code:
def day(x,y):
	start=0
	if (x==1 or x==10):
		start=3
	elif (x==2 or x==3 or x==11):
		start=6
	elif (x==4 or x==7):
		start=2
	elif x==5:
		start=4
	elif x==6:
		start=0
	elif x==8:
		start=5
	else:
		start=1
	day=(start+y)%7
	if day==1:
		return "Sunday"
	elif day==2:
		return "Monday"
	elif day==3:
		return "Tuesday"
	elif day==4:
		return "Wednesday"
	elif day==5:
		return "Thursday"
	elif day==6:
		return "Friday"
	else:#0
		return "Saturday"


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

Submission status: Wrong Answer

Solution code:
def day(x,y):
	start=0
	if x==2 or x==8 :
		start=0
	elif x==3 or x==11:
		start=1
	elif x==6:
		start=2
	elif x==9 or x==12:
		start=3
	elif x==1 or x==4:
		start=4
	else:
		start=6
	day=(start+y)%7
	if day==1:
		return "Sunday"
	elif day==2:
		return "Monday"
	elif day==3:
		return "Tuesday"
	elif day==4:
		return "Wednesday"
	elif day==5:
		return "Thursday"
	elif day==6:
		return "Friday"
	else:#0
		return "Saturday"


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import sys

days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Satday"]
while True:
    ans = 3
    m, d = map(int, raw_input().split())
    if m == 0 or d == 0:
        break
    for i in range(1, m):
        if i == 2:
            ans = (ans+1)%7
        elif i == 4 or i == 6 or i == 9 or i == 11:
            ans = (ans+2)%7
        else:
            ans = (ans+3)%7
    ans = (ans+d)%7
    print days[ans]

Submission status: Wrong Answer

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

import sys

days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Satday"]
while True:
    ans = 3
    m, d = map(int, raw_input().split())
    if m == 0:
        break
    for i in range(1, m):
        if i == 2:
            ans = (ans+1)%7
        elif i == 4 or i == 6 or i == 9 or i == 11:
            ans = (ans+2)%7
        else:
            ans = (ans+3)%7
    ans = (ans+d)%7
    print days[ans]

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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 = (s + 1) % 7
while 1:
    mon, day = map(int, raw_input().split())
    if mon == 0: break
    print w[c[mon - 1][day - 1]]

Submission status: Wrong Answer

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 - 2 * 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 == 2:
        print("Tuesday")
    elif You == 3:
        print("Monday")
    elif You == 4:
        print("Wednesday")
    elif You == 5:
        print("Thursday")
    elif You == 6:
        print("Friday")
    elif You == 0:
        print("Saturday")

Submission status: Wrong Answer

Solution code:
from datetime import date
week=["Monday","Trueday","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: Wrong Answer

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

import sys
import os
import datetime

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

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

    if month == 2 and day == 29:
        yday = datetime.date(2014, month, day - 1).timetuple().tm_yday + 1
    elif month == 3:
        yday = datetime.date(2014, month, day).timetuple().tm_yday + 1
    else:
        yday = datetime.date(2014, month, day).timetuple().tm_yday

    a = DAY_OF_WEEK[(3 + yday) % 7]
    print(a)

Submission status: Wrong Answer

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 % 7]
    month, day = map(int, raw_input().split())

Submission status: Wrong Answer

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+4) % 7]
    month, day = map(int, raw_input().split())

Submission status: Wrong Answer

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 x==1 or 3 or 5 or 7 or 8 or 10 or 12 :
                date += 31
            elif x==2:
                date +=29
            else:
                date+=30
        k=(date+y)%7
        print(lis[k])
    else:
        break

Submission status: Wrong Answer

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 6 or 9 or 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: Wrong Answer

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
        print(date)
        k=(date+y)%7
        print(date+y)
        print(lis[k])
    else:
        break

Submission status: Wrong Answer

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
  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: Wrong Answer

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
  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: Wrong Answer

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
  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: Wrong Answer

Solution code:
import datetime

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

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

Submission status: Wrong Answer

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(204, m, d).weekday()])

Submission status: Wrong Answer

Solution code:
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())
print(day[(month[m-1]+d)%7]+'day')

Submission status: Wrong Answer

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]
	try: m,d=map(int,input().split())
	except: break
	print(day[(month[m-1]+d)%7]+'day')

Submission status: Wrong Answer

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", "Minday", "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: Wrong Answer

Solution code:
day = ["Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"]
month = [31, 29, 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: Wrong Answer

Solution code:
day = ["Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"]
month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 31, 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: Wrong Answer

Solution code:
while True:
    a,b=map(int,raw_input().split())
    if a+b==0: break
    kari,day=a,0
    if a>2:
        day+=31+29+b
        kari-=2
        tt = range(1,kari+1)
        for i in tt:
            if kari == 1: break
            if i %2 != 0:
                day+=31
            elif i%2 == 0:
                day+=30
            kari -=1
    else:
        if a == 1:
            day = b
        elif a == 2:
            day = 31+b

    print ['Thursday','Friday','Saturday','Sunday','Monday','Tuesday','Wednewday'][(day%7)-1]

Submission status: Wrong Answer

Solution code:
while True:
    a,b=map(int,raw_input().split())
    if a+b==0: break
    kari,day=a,0
    if a>2:
        day+=31+29+b
        kari-=2
        tt = range(1,kari+1)
        for i in tt:
            if kari == 1: break
            if i %2 != 0:
                day+=31
            elif i%2 == 0:
                day+=30
            kari -=1
    else:
        if a == 1:
            day = b
        elif a == 2:
            day = 31+b

    print ['Thursday','Friday','Saturday','Sunday','Monday','Tuesday','Wednesday'][(day%7)-1]

Submission status: Wrong Answer

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
    nd = 0 
    for i in range(m):
       nd += nm[i]

    nd += d 
    n = nd%7
    if n == 1:
        print "Thursday"
    elif n == 2:
        print "Tryday"
    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: Wrong Answer

Solution code:
y = [31,29,31,30,31,30,31,31,30,31,30,31]
dow = {0:"Monday", 1:"Thuesday", 2:"Wednesday", 3:"Thursday", 4:"Friday", 5:"Saturday", 6:"Sunday"}

while True:
    m, d = map(int, raw_input().split())
    if m == 0 and d == 0:
        break
    n = 0
    for i in range(m):
        n += y[i]
    n -= (y[m-1]-d+1)
    print dow[(n+3)%7]

Submission status: Accepted

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


m=2
d=29

	

while True:
	m,d=map( int , raw_input().split() )
	if m==d==0:
		quit()
	else:
		x=0
		for i in range(m-1):
			x+=M[i]
		x+=d
		print DAY[x%7]

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from datetime import *

for line in sys.stdin:
    a, b = map(int,line.split())
    try:
        print(date(2004, a, b).strftime("%A"))
    except ValueError:
        break

Submission status: Accepted

Solution code:
#!/usr/bin/python

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:
import datetime

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

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

Submission status: Accepted

Solution code:
from datetime import date

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

while True:
  line = map(int, raw_input().split())
  if line[0] == 0: break
  print week[date(2004,line[0],line[1]).weekday()]

Submission status: Accepted

Solution code:
days=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']
dom=[31,29,31,30,31,30,31,31,30,31,30,31]
while True:
    try:
        try:
            (m,d)=map(int,raw_input().split())
        except: break
        if m==0 and d==0: break
        day=4-1
        for i in xrange(m-1):
            day+=dom[i]
        day+=d
        print days[day%7]
    except EOFError: break

Submission status: Accepted

Solution code:
days=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']
import calendar
while True:
    try:
        try:
            (m,d)=map(int,raw_input().split())
        except: break
        if m==0 and d==0: break
        print days[calendar.weekday(2004,m,d)]
    except EOFError: break

Submission status: Accepted

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

import sys
from datetime import date

def print_week(n):
  n_to_week = {0:"Monday",1:"Tuesday",2:"Wednesday",3:"Thursday",4:"Friday",5:"Saturday",6:"Sunday"}
  print n_to_week[n]

for s in sys.stdin:
  d = map(int,s.split())
  if d == [0,0]:
    exit()
  print_week(date(2004,d[0],d[1]).weekday())

Submission status: Accepted

Solution code:
import datetime
import sys

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

f = sys.stdin
while True:
    month, date = map(int, f.readline().split())
    if month == 0:
        break
    day = datetime.date(2004, month, date)
    print(week[day.weekday()])

Submission status: Accepted

Solution code:
from datetime import date
while True:
    m,d = map(int,raw_input().split(" "))
    
    if m ==0:
        break
        
    w = date(2004,m,d).isoweekday()

    if w==1:
        print 'Monday'
    elif w==2:
        print 'Tuesday'
    elif w==3:
        print 'Wednesday'
    elif w==4:
        print 'Thursday'
    elif w==5:
        print 'Friday'
    elif w==6:
        print 'Saturday'
    elif w==7:
        print 'Sunday'

Submission status: Accepted

Solution code:
import datetime

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

Submission status: Accepted

Solution code:
days_sum={1:31,2:29,3:31,4:30,5:31,6:30,7:31,8:31,9:30,
          10:31,11:30,12:31}
days2month={1:'Thursday',2:'Friday',3:'Saturday',4:'Sunday',
            5:'Monday',6:'Tuesday',0:'Wednesday'}

while True:
    month,day=map(int,raw_input().split(" "))
    if month==0 and day==0:
        break
    keika=0
    for i in range(1,month):
        keika += days_sum[i]
    keika+=day
    print days2month[keika%7]

Submission status: Accepted

Solution code:
import datetime

try:
	while 1:
		s = raw_input().split()
		s[0] = int(s[0])
		s[1] = int(s[1])
		
		if s[0] + s[1] == 0:
			exit()
		
		n = datetime.date(2004, s[0], s[1]).weekday()
		
		if n == 0:
			print("Monday")
		elif n == 1:
			print("Tuesday")
		elif n == 2:
			print("Wednesday")
		elif n == 3:
			print("Thursday")
		elif n == 4:
			print("Friday")
		elif n == 5:
			print("Saturday")
		elif n == 6:
			print("Sunday")
except:
	pass

Submission status: Accepted

Solution code:
from datetime import date
while 1:
	m,d=map(int,raw_input().split())
	if m==0:break
	print date(2004,m,d).strftime("%A")

Submission status: Accepted

Solution code:
def create(month, days):
    day = 1
    while week:
        calendar[(month, day)] = week[0]
        week.append(week[0])
        del week[0]
        if day == days: break
        day += 1
        
week = ['Thursday','Friday','Saturday','Sunday','Monday','Tuesday','Wednesday']
calendar = {}
for i in range(12):
    month = i+1
    if month in (1,3,5,7,8,10,12):
        create(month, 31)
    elif month == 2:
        create(month, 29)
    else:
        create(month, 30)
    
while True:
        month, day = map(int, raw_input().split())
        if month == 0 and day == 0: break
        print calendar[(month, day)]

Submission status: Accepted

Solution code:

import sys
import math

dayy = [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

def days(a, day):
    if a == 0:
        return day
    else:
        return days(a-1, day + dayy[a])


while 1:
    inp = raw_input().split()
    ii = int(inp[0])
    jj = int(inp[1])
    if ii == 0 and jj== 0:
        break
    ans = days(ii-1, 0) + jj
    ans = ans % 7
    if ans == 1:
        print "Thursday"
        continue
    if ans == 2:
        print "Friday"
        continue
    if ans == 3:
        print "Saturday"
        continue
    if ans == 4:
        print "Sunday"
        continue
    if ans == 5:
        print "Monday"
        continue
    if ans == 6:
        print "Tuesday"
        continue
    if ans == 0:
        print "Wednesday"
        continue

Submission status: Accepted

Solution code:
def create(month, days):
    day = 1
    while day <= days:
        calendar[(month, day)] = week[0]
        week.append(week[0])
        del week[0]
        day += 1
        
week = ['Thursday','Friday','Saturday','Sunday','Monday','Tuesday','Wednesday']
calendar = {}
for i in range(12):
    month = i+1
    if month in (1,3,5,7,8,10,12):
        create(month, 31)
    elif month == 2:
        create(month, 29)
    else:
        create(month, 30)
    
while True:
        month, day = map(int, raw_input().split())
        if month == 0 and day == 0: break
        print calendar[(month, day)]

Submission status: Accepted

Solution code:
def create(month, days):
    day = 1
    while day <= days:
        calendar[(month, day)] = week[0]
        week.append(week[0])
        del week[0]
        day += 1
        
week = ['Thursday','Friday','Saturday','Sunday','Monday','Tuesday','Wednesday']
calendar = {}
for i in range(12):
    month = i+1
    if month == 2:
        create(month, 29)
    elif month in (4,6,9,11):
        create(month, 30)
    else:
        create(month, 31)
    
while True:
        month, day = map(int, raw_input().split())
        if month == 0 and day == 0: break
        print calendar[(month, day)]

Submission status: Accepted

Solution code:
def create(month, days):
    for i in range(days):
        day = i+1
        calendar[(month, day)] = week[0]
        week.append(week[0])
        del week[0]
        
week = ['Thursday','Friday','Saturday','Sunday','Monday','Tuesday','Wednesday']
calendar = {}
for i in range(12):
    month = i+1
    if month == 2:
        create(month, 29)
    elif month in (4,6,9,11):
        create(month, 30)
    else:
        create(month, 31)
    
while True:
        month, day = map(int, raw_input().split())
        if month == 0 and day == 0: break
        print calendar[(month, day)]

Submission status: Accepted

Solution code:
import sys

day = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
num = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

for s in sys.stdin:
    M, D = map(int, s.strip().split())
    if M == 0:
        break
    totalDay = D
    M -= 1

    while M > 0:
        totalDay += num[M-1]
        M -= 1

    print(day[(totalDay+2)%7])

Submission status: Accepted

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

Submission status: Accepted

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

def main():
    LIST=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]

    while True:
        try:
            count=3
            M,D=map(int,input().split())
            if M==0:
                break

            if M in [1,4,7]:
                pass
            elif M in [10]:
                count+=1
            elif M in [5]:
                count+=2
            elif M in [2,8]:
                count+=3
            elif M in [3,11]:
                count+=4
            elif M in [6]:
                count+=5
            elif M in [9,12]:
                count+=6

            count+=D%7

            print(LIST[count%7])

        except:
            break

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from math import *
PI = 3.1415926535898
res = [0,31,29,31,30,31,30,31,31,30,31,30,31]
wk = ["Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"]
pas = [0]
for i in range(1, len(res)):
	pas.append(pas[i-1] + res[i])
while True:
	try:
		m, d = map(int, raw_input().strip().split(' '))
		if m == 0 and d == 0:
			break
		print wk[(pas[m-1]+d)%7]
	except EOFError:
		break

Submission status: Accepted

Solution code:
from datetime import date
import sys
for line in sys.stdin.readlines():
   m , d = map(int,line.split())
   if m != 0 and d != 0 :
       val = date(2004,m,d)
       day = val.isoweekday()
       if day == 7:
           print("Sunday")
       elif day == 1:
           print("Monday")
       elif day == 2:
           print("Tuesday")
       elif day == 3:
           print("Wednesday")
       elif day == 4:
           print("Thursday")
       elif day == 5:
           print("Friday")
       else:
           print("Saturday")
   else:
       break

Submission status: Accepted

Solution code:
def day(x,y):
	start=0
	if x==2 or x==8 :
		start=0
	elif x==3 or x==11:
		start=1
	elif x==6:
		start=2
	elif x==9 or x==12:
		start=3
	elif x==1 or x==4 or x==7:
		start=4
	elif x==10:
		start=5
	elif x==5:
		start=6 



	day=(start+y)%7
	if day==1:
		return "Sunday"
	elif day==2:
		return "Monday"
	elif day==3:
		return "Tuesday"
	elif day==4:
		return "Wednesday"
	elif day==5:
		return "Thursday"
	elif day==6:
		return "Friday"
	else:#0
		return "Saturday"


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#encoding=utf-8
import datetime

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

		date1 = datetime.date(2004,month,day)
		tag = date1.weekday()
		print syori(tag + 1)

def syori(m):
	if m == 1:
		return "Monday"
	elif m == 2:
		return "Tuesday"
	elif m == 3:
		return "Wednesday"
	elif m == 4:
		return "Thursday"
	elif m == 5:
		return "Friday"
	elif m == 6:
		return "Saturday"
	elif m == 7:
		return "Sunday"

if __name__ == "__main__":
	tako()

Submission status: Accepted

Solution code:
DAY_OF_WEEK = ['Sunday', 'Monday', 'Tuesday',
               'Wednesday', 'Thursday', 'Friday', 'Saturday']
def day_of_week(y, m, d):
    # ?????\?????????(?????§???????????¬???)
    # ??\?????\???0,????????\???6
    # Zeller's congruence
    if m == 1 or m == 2:
        m += 12
        y -= 1
    h = (y + y // 4 - y // 100 + y // 400 + (13 * m + 8) // 5 + d) % 7
    return h

while True:
    m,d = map(int, input().split())
    if m==0:
        exit()
    print(DAY_OF_WEEK[day_of_week(2004,m,d)])

Submission status: Accepted

Solution code:
from datetime import date
while 1:
	input_data = map(int,raw_input().split())
	day = 0
	if input_data[0] == 0:
		break
	day = date(2004,int(input_data[0]),int(input_data[1])).weekday()
	if day == 6:
		print("Sunday")
	elif day == 0:
		print("Monday")
	elif day == 1:
		print("Tuesday")
	elif day == 2:
		print("Wednesday")
	elif day == 3:
		print("Thursday")
	elif day == 4:
		print("Friday")
	elif day == 5:
		print("Saturday")

Submission status: Accepted

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

import sys

days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
while True:
    ans = 3
    m, d = map(int, raw_input().split())
    if m == 0:
        break
    for i in range(1, m):
        if i == 2:
            ans = (ans+1)%7
        elif i == 4 or i == 6 or i == 9 or i == 11:
            ans = (ans+2)%7
        else:
            ans = (ans+3)%7
    ans = (ans+d)%7
    print days[ans]

Submission status: Accepted

Solution code:
while True:
    m, d = map(int, input().split())
    if m == d == 0:
        break
    dim = {1: 0, 2: 31, 3: 60, 4: 91, 5: 121, 6: 152, 7: 182, 8: 213, 9: 244, 10: 274, 11: 305, 12: 335}
    ds = dim[m] + d -1
    print({0:'Thursday', 1:'Friday', 2:'Saturday', 3:'Sunday', 4:'Monday', 5:'Tuesday', 6:'Wednesday'}[ds % 7])

Submission status: Accepted

Solution code:
daymonth = [0, 2, 5, 6, 2, 4, 0, 2, 5, 1, 3, 6, 1]
str = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]


#print(input().split(" "))

m = 1
d = 1

while m!=0:
	md = input().split(" ")
	m = int(md[0])
	d = int(md[1])
	if m != 0:
		print(str[(daymonth[m] + d) % 7])

Submission status: Accepted

Solution code:
from datetime import date
while 1:
    m, d = map(int, raw_input().split())
    if m == d == 0: break
    ans = date(2004,m,d).weekday()
    ansday = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]
    for i in range(7):
        if ans == i: print ansday[i]