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<iostream>
using namespace std;

int Zellers_congruence(int y, int m, int d) {
	int num;
	if (m < 3)num = (y - 1) + (y - 1) / 4 - (y - 1) / 100 + (y - 1) / 400 + (13 * (m + 12) + 8) / 5 + d;
	else num = y + y / 4 + -y / 100 + y / 400 + (13 * m + 8) / 5 + d;
	return num % 7;
}

int main() {
	int year=2004, month, day;
	while (cin>>month>>day&&month!=0&&day!=0) {
		switch (Zellers_congruence(year, month, day)) {
		case 0: {cout << "Sunday" << endl; break; }
		case 1: {cout << "Monday" << endl; break; }
		case 2: {cout << "Tuesday" << endl; break; }
		case 3: {cout << "Wednesday" << endl; break; }
		case 4: {cout << "Thursday" << endl; break; }
		case 5: {cout << "Friday" << endl; break; }
		case 6: {cout << "Saturday" << endl; break; }
		default:cout << "error" << endl;
		}
	}
}

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

using namespace std;

int main()
{ 
	const string day[7] = { "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday" };
	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) - 1] << endl;
	}

	return 0;
}

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

int main()
{
	std::vector<std::string> day_of_week{
		"Thursday",
		"Friday",
		"Suterday",
		"Sunday",
		"Monday",
		"Tuesday",
		"Wednesday"
	};

	std::vector<int> day_num_of_month{
		31,
		29,
		31,
		30,
		31,
		30,
		31,
		31,
		30,
		31,
		30,
		31
	};

	int month = 0;
	int day = 0;

	while (std::cin >> month >> day)
	{
		if (0 == month) { break; }

		int days_elapsed = 0;
		for (int m = 1; m < month; ++m)
		{
			days_elapsed += day_num_of_month[m - 1];
		}
		days_elapsed += day;

		std::cout << day_of_week[(days_elapsed - 1) % 7] << std::endl;
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
	int M, D, days;
	int daysOfMonth[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	string daysOfWeek[] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};
	while (1) {
		cin >> M >> D;
		if (M == 0 && D == 0)
			break;
		days = 0;
		for (int i = 0; i < M; i++)
			days += daysOfMonth[i];
		days += D;
		cout << daysOfWeek[days % 7] << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;

#define EPS 1e-8

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

int main(){
	
	int m, d;
	while(cin >> m >> d, m, d){
		ll cnt = 3;
		rep(i, m-1) cnt += days[i];
		cnt += (d-1);
		cout << yobi[cnt%7] << endl;
	}
	


	
	return 0;
}

C++: #include<iostream>

int day_of_month( int m )
{
	switch( m ){
	 	case 2:
			return 29;
			break;
		case 4:
		case 6:
		case 9:
		case 11:
			return 30;
			break;
		default:
			return 31;
			break;
	}
}

int main()
{
	int m,d;
	const char week[][20] = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
	
	while( 1 ){
		std::cin >> m >> d;
		if( !m && !d ) break;
		
		int nm = 1, nd = 1, nw = 3;
		while( 1 ){
			if( nm == m && nd == d ) break;
			nd++;
			nw = ( nw + 1 ) % 7;
			
			if( nd > day_of_month( nm ) ){
			 	nd = 1;
				nm++;
			}
		}
		
		std::cout << week[nw] << std::endl;
	}

 	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
 
int month[] = {31,29,31,30,31,30,31,31,30,31,30,31};
string date[] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
 
int main(){
    int M, D;
    while( cin >> M >> D, M ){
        int d = 3;
        for(int i=0; i<M-1; i++ ){
            d += month[i];
        }
        d += D;
        d %= 7;
        cout << date[d] << endl;
    }
}

C++: #include<iostream>

using namespace std;

int main() {
	int mon, date;
	while (cin >> mon >> date) {
		if (mon == 0) {
			break;
		}
	int year = 2004, tmp;
		if (0 < mon && mon <= 2) {
			year -= 1;
			mon += 12;
		}
		tmp = year;
		tmp += int(year / 4);
		tmp -= int(year / 100);
		tmp += int(year / 400);
		tmp += int((mon * 13 + 8) / 5);
		tmp += date;
		tmp %= 7;
		if (tmp == 0) {
			cout << "Sunday" << endl;
		}
		if (tmp == 1) {
			cout << "Monday" << endl;
		}
		if (tmp == 2) {
			cout << "Tuesday" << endl;
		}
		if (tmp == 3) {
			cout << "Wednesday" << endl;
		}
		if (tmp == 4) {
			cout << "Thursday" << endl;
		}
		if (tmp == 5) {
			cout << "Friday" << endl;
		}
		if (tmp == 6) {
			cout << "Saturday" << endl;
		}




	}
}

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

using namespace std;

int main(){
	string y[7] = {"Wednesday", "Thrsday", "Frinday", "Saturday", "Sunday", "Monday", "Tuesday"};
	int mon[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

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

		while(m != 0){
			d = d + mon[m-1];
			m--;
		}
		cout << y[d%7] << endl;
	}
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

int main() {
	vector<lint>A;
	A = {0,31,29,31,30,31,30,31,31,30,31,30,31 };
	vector<lint>S(13);
	S[0] = A[0];
	for (lint i = 1; i < 13; i++) {
		S[i] = S[i - 1] + A[i];
	}
	vector<string>B;
	B = { "Monday","Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };

	lint M, D;
	while (cin >> M >> D,!(M==0&&D==0)) {
		lint ALL = S[M - 1] + D;
		//cout << ALL << enld;
		cout << B[(ALL+2) % 7] << endl;
	}
}