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++: #include "bits/stdc++.h"

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

const int dy[] = { 0, 1, 0, -1 };
const int dx[] = { 1, 0, -1, 0 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

int solve(int m, int d) {
	int y = 2004;
	if (m <= 2) {
		m += 12;
		y--; 
	}
	return (y + y / 4 - y / 100 + y / 400 + (13 * m + 8) / 5 + d) % 7;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int m, d;
	while (cin >> m >> d) {
		if (m == 0 && d == 0) break;

		switch (solve(m, d)) {
			case 0:
				cout << "Sunday" << endl;
				break;
			case 1:
				cout << "Monday" << endl;
				break;
			case 2:
				cout << "Tuesday" << endl;
				break;
			case 3:
				cout << "Wednesday" << endl;
				break;
			case 4:
				cout << "Thursday" << endl;
				break;
			case 5:
				cout << "Friday" << endl;
				break;
			case 6:
				cout << "Saturday" << endl;
				break;
		}
	}
	return 0;
}

C++: # include <iostream>
using namespace std;
int main(){
    int month,day,sum;
    cin >> month >> day;
    while(month != 0){
        sum = 0;
        switch(month){
            case 1: sum = day; break;
            case 2: sum = 31+day; break;
            case 3: sum = 60+day; break;
            case 4: sum = 91+day; break;
            case 5: sum = 121 + day;break;
            case 6: sum = 152 + day;break;
            case 7: sum = 182 +day;break;
            case 8: sum = 213 + day;break;
            case 9: sum = 244 +day;break;
            case 10: sum = 274 +day;break;
            case 11: sum = 305 + day;break;
            case 12: sum = 335 +day;break;
            }
            sum %= 7;
        switch(sum){
            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;
        }
        cin >> month >> day;
        }
}

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

using namespace std;

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

int main(){
  int M,D;
  string A[7] = {"Sunday",
                 "Monday",
                 "Tuesday",
                 "Wednesday",
                 "Thursday",
                 "Friday",
                 "Saturday"};

  while(cin >> M >> D,M){
    cout << A[zeller(M,D)] << endl;
  }
}

C++: #include<iostream>

using namespace std;

int main()
{
	for(;;){
		int month;
		int day;
		int flg;
		int i;
		
		int past = 0;
		
		cin >> month;
		cin >> day;
		
		if(month == 0 && day == 0){
			break;
		}
		
		
	//	cout << month << day << endl;
		
		
		for(i = 0; i < month-1; i++){
			if(i == 1){
				past+=29;
			}
			else if(i == 0 || i == 2 || i == 4 || i == 6 || i == 7 || i == 9|| i == 11){
				past += 31;
			}
			else{
				past += 30;
			}
		}
		
		past += day-1;
		past%=7;
		
		switch(past){
			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;
		}
	}
}

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

int main()
{
	int m, d;
	while(1){
		int ds = 0;
		cin >> m >> d;
		if(m == 0){
			break;
		}
		for (int i = 1; i < m; ++i)
		{
			if(i == 4 || i == 6 || i == 9 || i == 11){
				ds += 30;
			}else if(i == 2){
				ds += 29;
			}else{
				ds += 31;
			}
		}
		ds += d;
		//cerr << ds << endl;
		ds %= 7;
		switch(ds){
			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>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.wdt", "r", stdin);
	// 2004/01/01 is Thursday
	const string week[] = {
	"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
	const int days[] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; 
	string str = "";
	
	while (1){
		int month, day;		
//		stringstream ss(str);
//		ss >> month >> day;
		cin >> month >> day;
		if (month == 0 && day == 0){
			break;
		} // end if
		int num = 0;
		int i;
		for (i = 0; i < month; ++i){
			num += days[i];
		} // end for
		num += day;
//		cout << "num: " << num << endl;
		cout << week [( num - 1 ) % 7 + 3 ] << endl;
	} // end while
		
	return 0;
}

C++: #include<stdio.h>
int main(){
	int m,d,i;
	int W;
	int s=0;
	
	while(1){
		s=0;
		scanf("%d %d",&m,&d);
		if(m==0)break;
		for(i=1;i<m;i++){
			if(i==1 || i==3 || i==5 || i==7 || i==8 || i==10 || i==12)s+=31;
			else if(i==4 || i==6 || i==9 || i==11 )s+=30;
			else if(i==2)s+=29;
		}
		W=s+d;
		if(W%7==0)printf("Wednesay\n");
		else if(W%7==1)printf("Thursday\n");
		else if(W%7==2)printf("Friday\n");
		else if(W%7==3)printf("Saturday\n");
		else if(W%7==4)printf("Sunday\n");
		else if(W%7==5)printf("Monday\n");
		else if(W%7==6)printf("Tuesday\n");
		W=0;
	}
return 0;
}