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++: #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 % 7 + 2] << 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 += 3;
			}
			if (a == 3) {
				b += 4;
			}
			if (a == 4) {
				b += 0;
			}
			if (a == 5) {
				b += 2;
			}
			if (a == 6) {
				b += 5;
			}
			if (a == 7) {
				b += 0;
			}
			if (a == 8) {
				b += 3;
			}
			if (a == 9) {
				b += 6;
			}
			if (a == 10) {
				b += 1;
			}
			if (a == 11) {
				b += 4;
			}
			if (a == 12) {
				b += 6;
			}
		}
		//?????\????±????(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++){
		if (str[i]=="Wednesday") {
			cout << "Wedne";
			cout << "sday" << endl;
		}else cout << str[i] << endl;
	}

	char c;
	cin >> c;

	return 0;
}

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

int main()
{
	int day[366];
	int month[12] = {0,31,60,91,121,152,182,213,244,274,305,335};
	int m,d;
	
	for(int i=0;i<366;++i)
		day[i] = i%7;
	
	while(cin >> m >> d){
		if(!m)
			break;

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

	}
	return 0;
}

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

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

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

int main()
{
	int day[365];
	int month[12] = {0,31,60,91,121,152,182,212,243,273,304,334};
	int m,d;
	
	for(int i=0;i<365;++i)
		day[i] = i%7;
	
	while(cin >> m >> d){
		if(!m & !d)
			break;

		switch(day[month[m-1] + d]){
		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;
}