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>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <array>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>
#include <memory.h>
#include <map>
#include <math.h>
#include <utility>
#include <set>

#pragma warning(disable:4996)
using namespace std;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
typedef long long Int;
const double PI = 3.141592653589793238;
const Int INF = 999999999999;
typedef pair<int, int> P;

int S[3][3] = {
		{ 0, 1, 0 },
		{ 1, 1, 1 },
		{ 0, 1, 0 },
};
int M[3][3] = {
		{ 1, 1, 1 },
		{ 1, 1, 1 },
		{ 1, 1, 1 },
};
int L[5][5] = {
		{ 0, 0, 1, 0, 0 },
		{ 0, 1, 1, 1, 0 },
		{ 1, 1, 1, 1, 1 },
		{ 0, 1, 1, 1, 0 },
		{ 0, 0, 1, 0, 0 },
};

string week[7]{
		"Monday",
		"Tuesday",
		"Wednesday",
		"Thursday",
		"Friday",
		"Saturday",
		"Sunday"
};

int dd[11]{3,1,3,2,3,2,3,3,2,3,2};

int main()
{
	int m, d;
	while (cin >> m >> d, m&&d){
		int start = 3;
		int di(0);
		for (int i = 1; i < m; ++i){
			di += dd[i - 1];
		}
		di += (d - 1) % 7;
		di += start;
		di %= 7;
		cout << week[di] << endl;
	}
	return 0;

}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  vstr days = {
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday",
    "Sunday",
  };
  vi32 months = {
    31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
  };

  while (true) {
    int m, d; cin >> m >> d;
    if (m == 0) return;
    int cnt = d;
    rep(i, m - 1) cnt += months[i];
    cout << days[(cnt + 2) % 7] << '\n';
  }
}

C++: #include<iostream>
#include<map>
using namespace std;
int day[]={31,29,31,30,31,30,31,31,30,31,30,31};
int main(){
	int m,d;
	map<int,string>v;
	v[0]="Wednesday";
	v[1]="Thursday";
	v[2]="Friday";
	v[3]="Saturday";
	v[4]="Sunday";
	v[5]="Monday";
	v[6]="Tuesday";
	while(cin>>m>>d){
		if(m==0&&d==0)
			break;
		int temp=d;
		for(int i=1;i<m;i++)
			temp+=day[i-1];
		temp%=7;
		cout<<v[temp]<<endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


/* 曜日計算 (0日曜日 - 6土曜日)　*/
int Zeller(ll y, int m, int d){
  if(m <= 2){
    y--;
    m += 12;
  }
  return (y + y/4 - y/100 + y/400 + (13*m + 8)/5 + d) % 7;
}

char dayoftheweek[7][16] = {
  "Sunday",
  "Monday",
  "Tuesday",
  "Wednesday",
  "Thursday",
  "Friday",
  "Saturday"
};

int main(){
  while (1) {
    int y = 2004, m, d;

    scanf("%d%d", &m, &d);

    if (m == 0) break;

    puts(dayoftheweek[Zeller(y, m, d)]);
  }

  return 0;
}

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

// https://github.com/rippro/lib/blob/master/util/date.cpp

using namespace std;
typedef long long ll;

string day[] = {
    "Sunday",
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday"
};

string month[] = {
    "January",
    "February",
    "March",
    "April",
    "May",
    "June",
    "July",
    "August",
    "September",
    "October",
    "November",
    "December"
};

ll zeller(long y, long m, long d){
    if (m <= 2){
        y--;
        m += 12;
    }
    return (365 * y) + (y / 4) - (y / 100) + (y / 400) + (306 * (m + 1)) / 10 + d - 429;
}

bool leap_year(int y){
    return y % 400 == 0 || (y % 4 == 0 && y % 100 != 0);
}

#define loop(i,a,b) for(ll i=(a); i<ll(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int m, d;
    while (cin >> m >> d && m){
        cout << day[(zeller(2004, m, d) + 1) % 7] << endl;
    }
}

C++: #include <iostream>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;


int days[] = {0,31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string week[] = {"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
 
int main()
{
	int m, d;
    while(cin >> m >> d && m && d)
    {
        int sum = 0;
        rep(i,m)
        {
            sum += days[i];
        }
        sum += d;
        cout << week[(sum)%7] << endl;
    }

    return 0;
}