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++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

constexpr int fairfield(int y, int m, const int &d) {
  if (m == 1 || m == 2) y--, m += 12;
  return 365 * y + y / 4 - y / 100 + y / 400 + 306 * (m + 1) / 10 + d - 428;
}

void solve() {
  int m, d;
  string t[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
  while (cin >> m >> d, m) {
    cout << t[(fairfield(2014, m, d) + 1) % 7] << endl;
  }
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main()
{
  int calen[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
  int month,day;
  int ans = 0;

  while(cin >> month >> day){
    if(month == 0)break;
    
    ans = 0;

    for(int i = 0;i < month-1;i++){
      ans += calen[i];
    }

    ans += day;

    switch (ans % 7) {
    case 0 : cout << "Wednesday" << endl;
      break;
    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;
    }

  }
}

C++: #include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <climits>
#include <utility>

#define PRINT(STR) cout << STR << endl;
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define SPACE " "

typedef long long ll;

using namespace std;

int nextInt() { int n = -1; cin >> n; return n; }
double nextDouble() { double d = -1; cin >> d; return d; }
ll nextll() { ll n = -1; cin >> n; return n; }
string nextString() { string str; cin >> str; return str; }

int INF = 1LL << 25;
double EPS = 1e-9;

// BEGIN //////////////////////////////////////////////////////////////
int main() {
	const int months[13] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	const string answers[7] =
	{ "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday" };
	while (true) {
		int M = nextInt();
		int D = nextInt();
		if (M == 0) break;
		int past_days = -1;
		for (int i = 1; i < M; i++) {
			past_days += months[i];
		}
		past_days += D;
		PRINT(answers[past_days % 7]);
	}
	return 0;
}
// END   //////////////////////////////////////////////////////////////

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

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

int daysPerMonth[11] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30 };

int main()
{
	int m, d;
	while (cin >> m >> d, m + d)
	{
		int day = 0;
		for (int i = 0; i < m - 1; i++)
		{
			day += daysPerMonth[i];
		}
		day += d;

		cout << days[day % 7] << endl;
	}

	return 0;
}

C++: int zeller(int y , int m , int d){
	if(m==1 || m==2) m+=12; y-=1;
	return(y + y/4 - y/100 + y/400 + ((13*m+8)/5) + d )%7;
}

int main(){
	int m , d , w=4 , fw;
	while (cin >> m >> d, m){
		switch(zeller(2004,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;
		}
	}
	return 0; 
}

C++: //#define _USE_MATH_DEFINES
//#include <cmath>
#include <iostream>
//#include <stdio.h>
//#include <stdlib.h>
//#include <iomanip>
//#include <vector>
#include <string>
//#include <algorithm>
//#include <functional>
#include <time.h>
//#include <sstream>
//#include <queue>

using namespace std;


int main(){

	int m, d;
	int days[13] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	int sum = 0;
	string wd[7] = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };


	while (cin >> m >> d){
		if (m == 0)break;
		sum = 0;

		for (int i = 1; i < m; i++){
			sum += days[i];
		}
		sum += d;

		cout << wd[(sum+2) % 7] << endl;

	}


	return 0;
}

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
using namespace std;

int main() {
	int m, d;
	while (cin >> m >> d&&m != 0 && d != 0) {
		int sum = 0;
		for (int i = 1; i < m; i++) {
			if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) {
				sum += 31;
			}
			else if (i == 2) {
				sum += 29;
			}
			else {
				sum += 30;
			}
		}
		sum += d;
		if (sum % 7 == 1) {
			cout << "Thursday" << endl;
		}
		else if (sum % 7 == 2) {
			cout << "Friday" << endl;
		}
		else if (sum % 7 == 3) {
			cout << "Saturday" << endl;
		}
		else if (sum % 7 == 4) {
			cout << "Sunday" << endl;
		}
		else if (sum % 7 == 5) {
			cout << "Monday" << endl;
		}
		else if (sum % 7 == 6) {
			cout << "Tuesday" << endl;
		}
		else {
			cout << "Wednesday" << endl;
		}
	}
}

C++: #include <iostream>
#include <string>
using namespace std;
int main() {
  int m[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  string w[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
    "Saturday", "Sunday"};
  int x, y;
  while (cin >> x >> y) {
    if (x == 0) break;
    int d = 2;
    while (--x)
      d += m[x];
    d += y;
    cout << w[d % 7] << endl;
  }
}