Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func zeller(month, day int) int {
	year := 2004
	if month == 1 || month == 2 {
		year--
		month += 12
	}
	return (year + year/4 - year/100 + year/400 + (13*month+8)/5 + day)%7
}

func main() {
	scanner.Split(bufio.ScanWords)
	for {
		month := nextInt()
		day := nextInt()
		if month == 0 && day == 0{
			break
		}
		switch zeller(month, day) {
		case 0:
			fmt.Println("Sunday")
		case 1:
			fmt.Println("Monday")
		case 2:
			fmt.Println("Tuesday")
		case 3:
			fmt.Println("Wednesday")
		case 4:
			fmt.Println("Thursday")
		case 5:
			fmt.Println("Friday")
		case 6:
			fmt.Println("Saturday")
		}
	}
}

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

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
#define INF 114514
using namespace std;



int main(){
	while (1) {
		int i, j, count = -1, k;
		cin >> i >> j;
		if (i == 0 && j == 0) return 0;
		for (k = 1; k <= i - 1; k++) {
			if (k == 4 || k == 6 || k == 9 || k == 11) count += 30;
			else if (k == 2) count += 29;
			else count += 31;
		}
		count += j;
		count = count % 7;
		switch (count) {
		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 <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int main() {
	int day=0;
	int x,y;
	int md[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	string s[7]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
	while(true){
		cin>>x>>y;
		if(x==0) break;
		for(int i=0;i<x-1;i++){
			day+=md[i];
		}
		day+=y;
		day%=7;
		cout<<s[day]<<endl;
		day=0;		
	}
}

C++: #include <bits/stdc++.h>

using namespace std;

int zeller(int Y, int M, int D)
{
    if (M < 3) {
	Y--;
	M += 12;
    }
    return (Y+Y/4-Y/100+Y/400+(13*M+8)/5+D)%7;
}

int main()
{
    const string w[] = {
        "Sunday",
        "Monday",
        "Tuesday",
        "Wednesday",
        "Thursday",
        "Friday",
        "Saturday",
        "Sunday"
    };
        
    int M, D;
    while (cin >> M >> D, M) {
        cout << w[zeller(2004, M, D)] << endl;
    }
    return 0;
}