Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
	"time"
)

var sc = bufio.NewScanner(os.Stdin)

//Sliceconvtoi ...
func Sliceconvtoi() []int {
	strs := strings.Split(sc.Text(), " ")

	var ints []int
	var x int

	for _, s := range strs {
		x, _ = strconv.Atoi(s)
		ints = append(ints, x)
	}

	return ints
}

func main() {
	for sc.Scan() {
		i := Sliceconvtoi()

		if i[0] == 0 && i[1] == 0 {
			break
		}

		m := time.Month(i[0])
		d := i[1]
		t := time.Date(2004, m, d, 0, 0, 0, 0, time.Local)
		fmt.Println(t.Weekday())
	}

}

Python: 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')

Python: 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()])

Python: # 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")

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

Python: 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')

Python: while(True):
    m,d = map(int,input().split())
    if m==0 and d==0:
        break
    dn = sum([[31,29,31,30,31,30,31,31,30,31,30,31][a] for a in range(m-1)]) + d-1
    print(["Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"][dn%7])

Python: # 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()])

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

Python: 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()])

Python: import datetime
while 1:
    try:
        m,d=map(int, input().split())
        print(datetime.date(2004, m,d).strftime('%A'))
    except:break

Python: 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()])

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

Python: 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])

Python: 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]

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

Python: 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))

Python: # -*- 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)

Python: 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))

Python: 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()])

Python: import datetime
yobi = {0:"Monday",1:"Tuesday",2:"Wednesday",3:"Thursday",4:"Friday",5:"Saturday",6:"Sunday"}
try:
    while True:
        m, d= map(int, input().split())
        if m == 0 and d == 0 :
            exit()
        day = datetime.datetime.strptime("2004/" + str(m) + "/" + str(d),"%Y/%m/%d")
        if day.weekday() in yobi:
            output = yobi[int(day.weekday())]
            print(output)
except EOFError:
    pass

Python: while True:
    month,day=list(map(int, input().split()))
    if month==day==0:
        break
    month_day=[30,29,31,30,31,30,31,31,30,31,30,31]             #1から12
    tmp_day=0
    for i in range(month-1):
        tmp_day+=month_day[i]
    tmp_day+=day
    amari=tmp_day%7
    if month==day==1:
        print("Thursday")
    elif amari==0:
        print("Thursday")
    elif amari==1:
        print("Friday")
    elif amari==2:
        print("Saturday")
    elif amari==3:
        print("Sunday")
    elif amari==4:
        print("Monday")
    elif amari==5:
        print("Tuesday")
    elif amari==6:
        print("Wednesday")

Python: 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