Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

//Sliceconvtoi ...
func Sliceconvtoi() []int {
	strs := strings.Split(sc.Text(), " ")

	var ints []int
	var x int

	for _, s := range strs {
		x, _ = strconv.Atoi(s)
		ints = append(ints, x)
	}

	return ints
}

func main() {
	for sc.Scan() {
		i := Sliceconvtoi()

		if i[0] == 0 && i[1] == 0 {
			break
		}

		m := time.Month(i[0])
		d := i[1]
		t := time.Date(2004, m, d, 0, 0, 0, 0, time.Local)
		fmt.Println(t.Weekday())
	}

}

C++: #include<iostream>

using namespace std;

int main() {
	int mon, date;
	while (cin >> mon >> date) {
		if (mon == 0) {
			break;
		}
	int year = 2004, tmp;
		if (0 < mon && mon <= 2) {
			year -= 1;
			mon += 12;
		}
		tmp = year;
		tmp += int(year / 4);
		tmp -= int(year / 100);
		tmp += int(year / 400);
		tmp += int((mon * 13 + 8) / 5);
		tmp += date;
		tmp %= 7;
		if (tmp == 0) {
			cout << "Sunday" << endl;
		}
		if (tmp == 1) {
			cout << "Monday" << endl;
		}
		if (tmp == 2) {
			cout << "Tuesday" << endl;
		}
		if (tmp == 3) {
			cout << "Wednesday" << endl;
		}
		if (tmp == 4) {
			cout << "Thursday" << endl;
		}
		if (tmp == 5) {
			cout << "Friday" << endl;
		}
		if (tmp == 6) {
			cout << "Saturday" << endl;
		}




	}
}

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

using namespace std;

int main(){
	string y[7] = {"Wednesday", "Thrsday", "Frinday", "Saturday", "Sunday", "Monday", "Tuesday"};
	int mon[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

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

		while(m != 0){
			d = d + mon[m-1];
			m--;
		}
		cout << y[d%7] << endl;
	}
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

int main() {
	vector<lint>A;
	A = {0,31,29,31,30,31,30,31,31,30,31,30,31 };
	vector<lint>S(13);
	S[0] = A[0];
	for (lint i = 1; i < 13; i++) {
		S[i] = S[i - 1] + A[i];
	}
	vector<string>B;
	B = { "Monday","Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };

	lint M, D;
	while (cin >> M >> D,!(M==0&&D==0)) {
		lint ALL = S[M - 1] + D;
		//cout << ALL << enld;
		cout << B[(ALL+2) % 7] << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;

const string day[] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};
const int da[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main(void){
  int m, d;
  while(cin >> m >> d, m | d){
    while(1){
      m--;
      if(m > 0){
        d += da[m];
      }else{
        break;
      }
    }
    cout << day[d%7] << endl;
  }
  return 0;
}

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