Go: package main

import "fmt"

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

	for {
		var m, d int
		fmt.Scan(&m, &d)
		if m == 0 {
			break
		}

		for i := 0; i < m-1; i++ {
			d += days[i]
		}

		fmt.Println(weekday[d%7])
	}
}

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;
}