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

int main(){
	int n,m;
	string a="Monday",s="Tuesday",d="Wednesday",f="Thursday",g="Friday",h="Saturday",j="Sunday";
	while(cin>>n>>m,n||m){
		if(n==4||n==6||n==9||n==11){
			if(n==4){
				if(m==1||m==8||m==15||m==22||m==29)cout<<f<<endl;
				else if(m==2||m==9||m==16||m==23||m==30)cout<<g<<endl;
				else if(m==3||m==10||m==17||m==24)cout<<h<<endl;
				else if(m==4||m==11||m==18||m==25)cout<<"Sunday"<<endl;
				else if(m==5||m==12||m==19||m==26)cout<<"Monday"<<endl;
				else if(m==6||m==13||m==20||m==27)cout<<"Tuesday"<<endl;
				else if(m==7||m==14||m==21||m==28)cout<<"Wednesday"<<endl;
			}
			else if(n==6){
				if(m==1||m==8||m==15||m==22||m==29)cout<<s<<endl;
				else if(m==2||m==9||m==16||m==23||m==30)cout<<d<<endl;
				else if(m==3||m==10||m==17||m==24||m==31)cout<<f<<endl;
				else if(m==4||m==11||m==18||m==25)cout<<g<<endl;
				else if(m==5||m==12||m==19||m==26)cout<<h<<endl;
				else if(m==6||m==13||m==20||m==27)cout<<j<<endl;
				else if(m==7||m==14||m==21||m==28)cout<<a<<endl;
			}
			else if(n==9){
				if(m==1||m==8||m==15||m==22||m==29)cout<<d<<endl;
				else if(m==2||m==9||m==16||m==23||m==30)cout<<f<<endl;
				else if(m==3||m==10||m==17||m==24||m==31)cout<<g<<endl;
				else if(m==4||m==11||m==18||m==25)cout<<h<<endl;
				else if(m==5||m==12||m==19||m==26)cout<<j<<endl;
				else if(m==6||m==13||m==20||m==27)cout<<a<<endl;
				else if(m==7||m==14||m==21||m==28)cout<<s<<endl;
			}
			else{
				if(m==1||m==8||m==15||m==22||m==29)cout<<a<<endl;
				else if(m==2||m==9||m==16||m==23||m==30)cout<<s<<endl;
				else if(m==3||m==10||m==17||m==24||m==31)cout<<d<<endl;
				else if(m==4||m==11||m==18||m==25)cout<<f<<endl;
				else if(m==5||m==12||m==19||m==26)cout<<g<<endl;
				else if(m==6||m==13||m==20||m==27)cout<<h<<endl;
				else if(m==7||m==14||m==21||m==28)cout<<j<<endl;
			}
		}
		else if(n==1||n==3||n==5||n==7||n==8||n==10||n==12){
			if(n==1){
				if(m==1||m==8||m==15||m==22||m==29)cout<<"Thursday"<<endl;
				else if(m==2||m==9||m==16||m==23||m==30)cout<<"Friday"<<endl;
				else if(m==3||m==10||m==17||m==24||m==31)cout<<"Saturday"<<endl;
				else if(m==4||m==11||m==18||m==25)cout<<"Sunday"<<endl;
				else if(m==5||m==12||m==19||m==26)cout<<"Monday"<<endl;
				else if(m==6||m==13||m==20||m==27)cout<<"Tuesday"<<endl;
				else if(m==7||m==14||m==21||m==28)cout<<"Wednesday"<<endl;
			}
			else if(n==3){
				if(m==1||m==8||m==15||m==22||m==29)cout<<a<<endl;
				else if(m==2||m==9||m==16||m==23||m==30)cout<<s<<endl;
				else if(m==3||m==10||m==17||m==24||m==31)cout<<d<<endl;
				else if(m==4||m==11||m==18||m==25)cout<<f<<endl;
				else if(m==5||m==12||m==19||m==26)cout<<g<<endl;
				else if(m==6||m==13||m==20||m==27)cout<<h<<endl;
				else if(m==7||m==14||m==21||m==28)cout<<j<<endl;
			}
			else if(n==5){
				if(m==1||m==8||m==15||m==22||m==29)cout<<h<<endl;
				else if(m==2||m==9||m==16||m==23||m==30)cout<<j<<endl;
				else if(m==3||m==10||m==17||m==24||m==31)cout<<a<<endl;
				else if(m==4||m==11||m==18||m==25)cout<<s<<endl;
				else if(m==5||m==12||m==19||m==26)cout<<d<<endl;
				else if(m==6||m==13||m==20||m==27)cout<<f<<endl;
				else if(m==7||m==14||m==21||m==28)cout<<g<<endl;
			}
			else if(n==7){
				if(m==1||m==8||m==15||m==22||m==29)cout<<f<<endl;
				else if(m==2||m==9||m==16||m==23||m==30)cout<<g<<endl;
				else if(m==3||m==10||m==17||m==24||m==31)cout<<h<<endl;
				else if(m==4||m==11||m==18||m==25)cout<<j<<endl;
				else if(m==5||m==12||m==19||m==26)cout<<"Monday"<<endl;
				else if(m==6||m==13||m==20||m==27)cout<<"Tuesday"<<endl;
				else if(m==7||m==14||m==21||m==28)cout<<"Wednesday"<<endl;
			}
			else if(n==8){
				if(m==1||m==8||m==15||m==22||m==29)cout<<j<<endl;
				else if(m==2||m==9||m==16||m==23||m==30)cout<<a<<endl;
				else if(m==3||m==10||m==17||m==24||m==31)cout<<s<<endl;
				else if(m==4||m==11||m==18||m==25)cout<<d<<endl;
				else if(m==5||m==12||m==19||m==26)cout<<f<<endl;
				else if(m==6||m==13||m==20||m==27)cout<<g<<endl;
				else if(m==7||m==14||m==21||m==28)cout<<h<<endl;
			}
			else if(n==10){
				if(m==1||m==8||m==15||m==22||m==29)cout<<g<<endl;
				else if(m==2||m==9||m==16||m==23||m==30)cout<<h<<endl;
				else if(m==3||m==10||m==17||m==24||m==31)cout<<j<<endl;
				else if(m==4||m==11||m==18||m==25)cout<<a<<endl;
				else if(m==5||m==12||m==19||m==26)cout<<s<<endl;
				else if(m==6||m==13||m==20||m==27)cout<<d<<endl;
				else if(m==7||m==14||m==21||m==28)cout<<f<<endl;
			}
			else{
				if(m==1||m==8||m==15||m==22||m==29)cout<<d<<endl;
				else if(m==2||m==9||m==16||m==23||m==30)cout<<f<<endl;
				else if(m==3||m==10||m==17||m==24||m==31)cout<<g<<endl;
				else if(m==4||m==11||m==18||m==25)cout<<h<<endl;
				else if(m==5||m==12||m==19||m==26)cout<<j<<endl;
				else if(m==6||m==13||m==20||m==27)cout<<a<<endl;
				else if(m==7||m==14||m==21||m==28)cout<<s<<endl;
			}
		}
		else{
			if(m==1||m==8||m==15||m==22||m==29)cout<<j<<endl;
			else if(m==2||m==9||m==16||m==23)cout<<a<<endl;
			else if(m==3||m==10||m==17||m==24)cout<<s<<endl;
			else if(m==4||m==11||m==18||m==25)cout<<d<<endl;
			else if(m==5||m==12||m==19||m==26)cout<<f<<endl;
			else if(m==6||m==13||m==20||m==27)cout<<g<<endl;
			else if(m==7||m==14||m==21||m==28)cout<<h<<endl;
		}
	}
}

C++: #include<iostream>
#include<string>
using namespace std;
string d[7]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
int x[12]={31,29,31,30,31,30,31,31,30,31,30,31};
int y[12][31];
int main(){
	int a,b;
	while(true){
		cin>>a>>b;
		if(a==0){break;}
		int cnt=0;
		for(int i=0;i<12;i++){
			for(int j=0;j<x[i];j++){
				y[i][j]=cnt;
				cnt++;
			}
		}
		int D=y[a-1][b-1];
		D=(D+4)%7;
		cout<<d[D]<<endl;
	}
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>
#include <cassert>

using namespace std;


bool solve(){
	
	string str[7] = {
		"Monday",
		"Tuesday",
		"Wednesday",
		"Thursday",
		"Friday",
		"Saturday",
		"Sunday"
	};
	int hoge[]={31,29,31,30,31,30,31,31,30,31,30,31};
	int m, d;
	while(1){
		cin>> m>> d;
		if(m==0&&d==0) break;
		int num = d;
		for(int i=0;i<m-1;i++){
			num += hoge[i];
		}
		int day = (2+num)%7;
		cout<< str[day]<< endl;
		
	}
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

int main(){
    int m, d;
    while (cin>>m>>d){
        if (m == 0) break;
        int dow = 3, num[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        vector<string> str;
        str.push_back("Monday");
        str.push_back("Tuesday");
        str.push_back("Wednesday");
        str.push_back("Thursday");
        str.push_back("Friday");
        str.push_back("Saturday");
        str.push_back("Sunday");

        int sum = 0;
        for (int i=0; i < m-1; i++)
            sum += num[i];
        sum += d+2;
        cout << str[sum%7] << endl;
    }
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(ll i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main() {
	int a, b;
	string day[] = { "Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday" };
	int months[] = { 31,29,31,30,31,30,31,31,30,31,30,31 };
	while (cin >> a >> b, a) {
		a--; b--;
		rep(i, a)b += months[i];
		cout << day[b % 7] << endl;
	}
	return 0;
}