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>
#include<string>
using namespace std;

class Days{
	string week;
public:
	Days() : week("Thursday"){}
	void calcDays(int,int);
	int monthToDays(int);
	void calcWeek(int);
	void setWeek(int);
	const string getWeek(void);
};

int Days::monthToDays(int month){
	if(month == 2)
		return 29;//うるう年
	if(month == 4 || month == 6 || month == 9 || month == 11)
		return 30;
	return 31;
}

void Days::calcDays(int month,int days){
	week = ("Thursday");//コンストラクタで初期化済みだが念のために
	int day = 0;//1月1日から何日経ったか
	for(int i = 1; i < month; i++){
		day += monthToDays(i);
	}
	day += (days - 1);
	calcWeek(day);
}

void Days::calcWeek(int day){
	setWeek(day %= 7);
}

const string Days::getWeek(void){
	return week;
}

void Days::setWeek(int day){
	switch(day){
	case 0:
		week = "Thursday";
		break;
	case 1:
		week = "Friday";
		break;
	case 2:
		week = "Saturday";
		break;
	case 3:
		week = "Sunday";
		break;
	case 4:
		week = "Monday";
		break;
	case 5:
		week = "Tuesday";
		break;
	case 6:
		week = "Wednesday";
		break;
	}
}

int main(){
	Days d;
	int month,day;
	while(1){
		cin >> month >> day;
		if(month == 0 || day == 0)
			break;
		d.calcDays(month,day);
		cout << d.getWeek() << endl;
	}
	return 0;
}

C++: 
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0027&lang=jp

#include<iostream>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define all(c) (c).begin(), (c).end()

using namespace std;
template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, T b) { if(b < a) a = b; }

int main() {
	int year = 2004;
	int month,day;
	string week[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
	
	while(true) {
		cin >> month >> day;
		if (month == 0 && day == 0) { break; }
		int month_ = month;
		if(month < 3){ year--; month_+=12; }
		if(month_ == 14){ day += 1; }
		int w = ((year + (year/4) - (year/100) + (year/400) + (((13 * month_) + 8)/5) + day) % 7);
		cout << week[w] << endl;
	}
	
	return 0;
}

C++: // includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
int offset[12] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};
string date[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

int main(int argc, char const* argv[])
{
  int m, d;
  while(cin >> m >> d){
    if(m == 0 && d == 0)break;
    int days = offset[m - 1] + d;
    days = (2 + days) % 7;
    cout << date[days] << endl;
  }
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(x=from;x<to;x++)

using namespace std;


int main(void){

int mm,dd;
int lday[] = {31,29,31,30,31,30,31,31,30,31,30,31};
string yob[7] = {"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
	
	while(cin >> mm >> dd ){
		if(mm == 0) break;
		int wkdd=dd;
		if( mm > 1) rep(i,mm-1) wkdd += lday[i];
//		cout << wkdd << endl;
		wkdd = wkdd % 7;
		cout <<  yob[wkdd] << endl;;
			
	}
	return 0;
}

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

using namespace std;

void Solution()
{
    int month;
    int day;
    
    string week[7] = {
        "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"
    };
    
    int mDays[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    
    while(cin>>month>>day)
    {
        int sum = 0;
        
        if (month == 0)
        {
            break;
        }
        
        for (int i = 0; i < month - 1; i++)
        {
            sum = mDays[i] + sum;
        }
        
        cout<<week[(sum + day) % 7]<<endl;
    }
}

int main()
{
    Solution();
    return 0;
}

C++: #include <iostream>
using namespace std;
int main()
{
	const int month[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	while(1)
	{
		int a,b,count=0;
		cin >> a >> b;
		if(a==0&&b==0)break;
		for(int i=0;i<(a-1);i++)
		{
			count += month[i];
		}
		count += b;
		count %= 7;
		switch(count)
		{
			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;
			case 0:cout << "Wednesday" << endl;break;
		}
	}
	return 0;
}

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