Go: package main

import (
        "fmt"
)

func main() {
        var weeks = []string{"Thursday",
                "Friday",
                "Saturday",
                "Sunday",
                "Monday",
                "Tuesday",
                "Wednesday"}

        for {
                var m, d int
                _, err := fmt.Scanf("%d %d", &m, &d)
                if err != nil || m + d == 0 {
                        break
                }
                var days int

                for {
                        lm, ld := getLastDay(m, d)
                        if lm + ld == 0 {
                                break
                        }
                        days++
                        m = lm
                        d = ld
                }
                fmt.Println(weeks[days%7])
        }
}

func getLastDay(m int, d int) (lm int, ld int) {
        if m == 1 && d == 1 {
                return 0, 0
        }

        if d > 1 {
                return m, d-1
        } else {
                if m == 3 {
                        return m-1, 29
                }
                if m == 3 || m == 5 || m == 7 || m == 10 || m == 12 {
                        return m-1, 30
                } else {
                        return m-1, 31
                }
        }
}

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

int main(void){
	while(1){
		int month, day;
		int days_from_new_year = 0;
		cin >> month >> day;
		if(month == 0 && day == 0) break;
		for(int i = 1; i < month; i++){
			if(i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) days_from_new_year += 31;
			else if(i == 4 || i == 6 || i == 9 || i == 11) days_from_new_year += 30;
			else if(i == 2) days_from_new_year += 29;
		}
		days_from_new_year += day;
		int mod = days_from_new_year % 7;
		if(mod == 0) cout << "Wednesday";
		else if(mod == 1) cout << "Thursday";
		else if(mod == 2) cout << "Friday";
		else if(mod == 3) cout << "Saturday";
		else if(mod == 4) cout << "Sunday";
		else if(mod == 5) cout << "Monday";
		else if(mod == 6) cout << "Tuesday";
		cout << endl;
	}
	return 0;
}

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

int main() {
	int m, d;
	string week[] = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
			"Saturday", "Sunday" };
	int day[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	while (cin >> m >> d) {
		if (m == 0)break;
		bool flag=false;
		int mc = 1;
		int cnt = 3;
		while (1) {
			for (int i = 1; i < day[mc - 1]; ++i, cnt++) {
				if (mc == m && d == i) {
					cout << week[cnt % 7] << endl;
					flag=true;
					break;
				}
			}
			if(flag)break;
			mc++;
		}
	}
	return 0;
}

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

int calendar[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
	int month, day;
	while (1) {
		int sum = 0;
		cin >> month >> day;
		if (month == 0) break;
		for (int i = 0; i < month - 1; i++) {
			sum += calendar[i];
		}
		sum += day;
		if (sum % 7 == 0) cout << "Wednesday" << endl;
		if (sum % 7 == 1) cout << "Thursday" << endl;
		if (sum % 7 == 2) cout << "Friday" << endl;
		if (sum % 7 == 3) cout << "Saturday" << endl;
		if (sum % 7 == 4) cout << "Sunday" << endl;
		if (sum % 7 == 5) cout << "Monday" << endl;
		if (sum % 7 == 6) cout << "Tuesday" << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

#define vcitr vector<int>::iterator
#define vcsitr vector<string>::iterator
#define mapcitr map<char, int>::iterator
#define mapsitr map<string, int>::iterator

typedef long long ll;

int iINF = 2147483647;
ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }

string day[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
int len[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
	int x, y;
	
	while (cin >> x >> y) {
		if (x==0 && y==0) break;
		x--; y--;
		
		int ans = 3;
		for_(i, 0, x) for_(j, 0, len[i]) {
			ans++; ans %= 7;
		}
		cout << day[ans] << endl;
	}
	
	return 0;
}

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

int main(){
  int str[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
  int mon,day;
  while(cin >>mon >>day){
    if(mon==0&&day==0)break;
    for(int i = 0 ; i < mon ; i++)
      day += str[i];
    day=day%7;
    if(day==0)cout<<"Wednesday"<<endl;
    else if(day==1)cout<<"Thursday"<<endl;
    else if(day==2)cout<<"Friday"<<endl;
    else if(day==3)cout<<"Saturday"<<endl;
    else if(day==4)cout<<"Sunday"<<endl;
    else if(day==5)cout<<"Monday"<<endl;
    else cout<<"Tuesday"<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.wdt", "r", stdin);
	// 2004/01/01 is Thursday
	const string week[] = {
	"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
	const int days[] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; 
	string str = "";
	
	while (getline (cin, str ) ){
		int day, month;		
		stringstream ss(str);
		ss >> month >> day;
		if (month == 0 && day == 0){
			break;
		} // end if
		int num = 0;
		int i;
		for (i = 0; i < month; ++i){
			num += days[i];
		} // end for
		num += day;
//		cout << "num: " << num << endl;
		cout << week [( num - 1 ) % 7 + 3 ] << endl;
	} // end for
		
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <queue>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <cctype>
#include <cstdlib>
using namespace std;

#define INF (1 << 20)
#define EPS (1e-10)
#define EQ(a,b) (fabs((a)-(b)) < EPS)

int main(){
	int dn[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	string youbi[7] = {"Monday", "Tuesday", "Wednesday", "Thursday",
		"Friday", "Saturday", "Sunday"};
	int m, d;
	while (cin >> m >> d) {
		if (m == 0) break;
		int sum = 0;
		for (int i = 1; i < m; ++i) {
			sum += dn[i];
		}
		sum += d;
		cout << youbi[(sum + 2) % 7] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
int main(){
	int month,day;
	const int monthday[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	const std::string str[]={"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
	while(1){
		std::cin>>month>>day;
		if(month==0)break;
		int sum=day;
		for(int i=0;i<month;i++)sum+=monthday[i];
		std::cout<<str[sum%7-1]<<std::endl;
	}
	return 0;
	/*
	月曜日 Monday
	火曜日 Tuesday
	水曜日 Wednesday
	木曜日 Thursday
	金曜日 Friday
	土曜日 Saturday
	日曜日 Sunday
	*/
}