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: ans ={}
for i in range(1,13):
    if i%2 !=0:
        ans[str(i)] = 31
    else:
        ans[str(i)] = 30
ans['2']=29 
while True:
    a,b=map(int,raw_input().split())
    day =b
    if a+b == 0: break;
    if a == 1:   day = b;
    elif a == 2: day+=31
    else:
        for i in range(a):
            if i ==0: pass;
            day += ans[str(i)]
    print ['Wednesday','Thurday','Friday',
            'Saturday','Sunday','Monday',
            'Tuesday'][day%7]

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

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

Python: 
import datetime
L = [ "Monday", "Tuesday", "Wednesday", "Thursday","Friday",
      "Saturday", "Sunday" ]

while True:
    m, d = [int(x) for x in input().split()]
    if m == 0 and d == 0:
        break
    dt = datetime.datetime(2004, m, d)
    w = dt.weekday()
    print(L[w])

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

Python: day = [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30]
for i in range(2,12):
    day[i] += day[i-1]
week = ['Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday', 'Monday', 'Tuesday']
while True:
    M, D = map(int, input().split())
    if M==0:
        break
    days = day[M-1] + D
    print(week[days%7])

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

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

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

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

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

Python: import datetime
import calendar

def trans(month, day, year=2004):
    past = datetime.date(year, month, day)
    result = calendar.day_name[past.weekday()]
    return result
    
while True:
    month, day = map(int, input().split())
    if month == day == 0: break
    print(trans(month, day))

Python: #datetimeモジュールをインポートする
import datetime

#aとbが0になるまで処理を繰り返す
while True:
    a,b = map(int,input().split())
    if a == 0 and b == 0:break

    #detetimeモジュールを使い、youbiに代入し、"strftime"を使い、曜日を取得する
    youbi = datetime.datetime(2004,a,b)
    print(youbi.strftime("%A"))

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

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

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

Python: week = {"1": "Thursday", "2": "Friday", "3": "Saturday", "4": "Sunday", "5": "Monday", "6": "Tuesday", "7": "Wednesday"}
month = {"1": 0, "2": 31, "3": 60, "4": 91, "5": 121, "6": 152, "7": 182, "8": 213, "9": 244, "10": 274, "11": 305, "12": 335}
m, d = input().split()
while m != "0":
    days = month[m] + int(d)
    print(week[str(days % 7)])
    m, d = input().split()

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

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

Python: lst = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
while True:
    m, d = map(int, input().split())
    if m == 0:
        break
    
    if m == 1 or m == 4 or m == 7:
        print(lst[(d + 2) % 7])

    elif m == 2 or m == 8:
        print(lst[(d + 5) % 7])

    elif m == 3 or m == 11:
        print(lst[(d + 6) % 7])

    elif m == 5:
        print(lst[(d + 4) % 7])

    elif m == 6:
        print(lst[d % 7])

    elif m == 9 or m == 12:
        print(lst[(d + 1) % 7])

    else:
        print(lst[(d + 3) % 7])

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