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())
	}

}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(ll i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main() {
	int a, b;
	string day[] = { "Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday" };
	int months[] = { 31,29,31,30,31,30,31,31,30,31,30,31 };
	while (cin >> a >> b, a) {
		a--; b--;
		rep(i, a)b += months[i];
		cout << day[b % 7] << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n,m;
  int x[12] = {0,3,4,0,2,5,0,3,6,1,4,6};
  while(cin >>n>>m,n||m){
    if((m+x[n-1])%7 == 1) cout <<"Thursday"<<endl;
    if((m+x[n-1])%7 == 2) cout <<"Friday"<<endl;
    if((m+x[n-1])%7 == 3) cout <<"Saturday"<<endl;
    if((m+x[n-1])%7 == 4) cout <<"Sunday"<<endl;
    if((m+x[n-1])%7 == 5) cout <<"Monday"<<endl;
    if((m+x[n-1])%7 == 6) cout <<"Tuesday"<<endl;
    if((m+x[n-1])%7 == 0) cout <<"Wednesday"<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;

int main()
{
	int month[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	int m,day,sumday;
    while(1){
		cin >> m; // 月
		if (m==0){ break;}
		cin >> day;  //日付
		for(int i=0;i<m;i++){
			day+=month[i];
		}
		switch(day%=7){
			case 1:
				cout<<"Thursday"<<endl;
				break;
			case 2:
				cout<<"Friday"<<endl;
				break;
			case 3:
				cout<<"Saturday"<<endl;
				break;
			case 4:
				cout<<"Sunday"<<endl;
				break;
			case 5:
				cout<<"Monday"<<endl;
				break;
			case 6:
				cout<<"Tuesday"<<endl;
				break;
			default:
				cout<<"Wednesday"<<endl;
				break;
		}
		
	}
	return 0;
}

C++: #include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

const char dat[7][16] = {
    "Monday", "Tuesday", "Wednesday", "Thursday",
    "Friday", "Saturday", "Sunday",
};
const int s[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

int main() {
    for (;;) {
        int m, d;
        scanf("%d%d", &m, &d);
        if (m == 0 && d == 0) return 0;
        m--, d--;
        rep (i, m) d += s[i];
        puts(dat[(d+3)%7]);
    }
}

C++: #include <iostream>
#include <string>

using namespace std;

int main()
{ 
	const string day[7] = {  "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday" };
	const int days[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

	int month, date;

	while (cin >> month >> date, month)
	{
		int sum = 0;
		for (int i = 1; i < month; ++i)
			sum += days[i - 1];

		sum += date;
		cout << day[sum % 7] << endl;
	}

	return 0;
}

C++: #include <iostream>
using namespace std;

int main(){
  int m,d;
  int cnt;
  string days[7]={"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
  while(1){
    cnt = 0;
    cin >> m >> d;
    if(m == 0 && d == 0) break;
    cnt += d;
    for(m--;m>0;m--){
      switch (m){
      case 4:
      case 6:
      case 9:
      case 11:
	cnt += 30;
      case 2:
	cnt += 29;
      default:
	cnt += 31;
      }
    }
    cout << days[cnt%7-1] << endl;
  }
}

C++: // 2011/07/12 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int days[12];
	days[0]  = 0;
	days[1]  = days[0] +31;
	days[2]  = days[1] +29;
	days[3]  = days[2] +31;
	days[4]  = days[3] +30;
	days[5]  = days[4] +31;
	days[6]  = days[5] +30;
	days[7]  = days[6] +31;
	days[8]  = days[7] +31;
	days[9]  = days[8] +30;
	days[10] = days[9] +31;
	days[11] = days[10]+30;

	while(true){
		int m, d;
		cin >> m >> d;
		if(m==0)
			break;

		switch((days[m-1]+d)%7){
			case 0:
				cout << "Wednesday" << endl;
				break;
			case 1:
				cout << "Thursday" << endl;
				break;
			case 2:
				cout << "Friday" << endl;
				break;
			case 3:
				cout << "Saturday" << endl;
				break;
			case 4:
				cout << "Sunday" << endl;
				break;
			case 5:
				cout << "Monday" << endl;
				break;
			case 6:
				cout << "Tuesday" << endl;
				break;
		}
	}

	return 0;
}

C++: #include <iostream>
#include <cstring>
using namespace std;

int md[12] = {0,31,29,31,30,31,30,31,31,30,31,30};
char* day[7] = {"Mon","Tues","Wednes","Thurs","Fri","Satur","Sun"};

int main()
{
	int m,d;
	while(cin >> m >> d, m||d)
	{
		for(int i=0; i<m; i++)
		{
			d+=md[i];
		}
		cout << day[(d+2)%7] << "day" << endl;

	}
}

C++: #include <iostream>
#include <string>
using namespace std;

string week[] = {"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
int days[] = {31,29,31,30,31,30,31,31,30,31,30,31};

int main(){
    int month, day;
    while(cin >> month >> day, month+day){
        int n = 0;
        for(int i=1; i<month; i++){
            n += days[i-1];
        }
        n += day;
        n %= 7;
        cout << week[n] <<endl;
    }
    return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;

int main() {
	string str[50];
	int f;
	for (int i = 0;; i++) {
		int a, b;
		cin >> a >> b;
		if (a == 0 && b == 0) {			
			f = i;
			break;
		}
		{
			if (a == 2) {
				b += 31;
			}
			if (a == 3) {
				b += 60;
			}
			if (a == 4) {
				b += 91;
			}
			if (a == 5) {
				b += 121;
			}
			if (a == 6) {
				b += 152;
			}
			if (a == 7) {
				b += 182;
			}
			if (a == 8) {
				b += 213;
			}
			if (a == 9) {
				b += 244;
			}
			if (a == 10) {
				b += 274;
			}
			if (a == 11) {
				b += 305;
			}
			if (a == 12) {
				b += 335;
			}
		}
		//?????\????±????(52???73)
		{
			if ((b & 7) == 0) {
				str[i] = "Wednesday";
			}
			if ((b & 7) == 1) {
				str[i] = "Thursday";
			}
			if ((b & 7) == 2) {
				str[i] = "Friday";
			}
			if ((b & 7) == 3) {
				str[i] = "Saturday";
			}
			if ((b & 7) == 4) {
				str[i] = "Sunday";
			}
			if ((b & 7) == 5) {
				str[i] = "Monday";
			}
			if ((b & 7) == 6) {
				str[i] = "Tuesday";
			}
		}
	}

	for (int i = 0; i < f; i++){
		cout << str[i] << endl;
	}

	char c;
	cin >> c;

	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int m, d;
    int a[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    string w[] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};
    while (cin >> m >> d, m)
    {
        int s = 0;
        rep(i, m - 1) s += a[i];
        cout << w[(s + d) % 7] << endl;
    }
}

C++: #include <iostream>
#include <cstdio>

int main(int argc, const char * argv[])
{
    int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int m, d;
    while (scanf("%d %d", &m, &d) != 0) {
        int cnt = 0;
        if (m == 0 && d == 0) {
            return 0;
        }
        for (int i = 0; i < m - 1; i++) {
            cnt += month[m - 1];
        }
        cnt += d;

        if (cnt % 7 == 1) {
            printf("Wednesday\n");
        }
        if (cnt % 7 == 2) {
            printf("Thursday\n");
        }
        if (cnt % 7 == 3) {
            printf("Friday\n");
        }
        if (cnt % 7 == 4) {
            printf("Saturday\n");
        }
        if (cnt % 7 == 5) {
            printf("Sunday\n");
        }
        if (cnt % 7 == 6) {
            printf("Monday\n");
        }
        if (cnt % 7 == 0) {
            printf("Tuesday\n");
        }
    }
    return 0;
}