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++: #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int m, d;
    int a[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    string w[] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};
    while (cin >> m >> d, m)
    {
        int s = 0;
        rep(i, m - 1) s += a[i];
        cout << w[(s + d) % 7] << endl;
    }
}

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

int main(int argc, const char * argv[])
{
    int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int m, d;
    while (scanf("%d %d", &m, &d) != 0) {
        int cnt = 0;
        if (m == 0 && d == 0) {
            return 0;
        }
        for (int i = 0; i < m - 1; i++) {
            cnt += month[m - 1];
        }
        cnt += d;

        if (cnt % 7 == 1) {
            printf("Wednesday\n");
        }
        if (cnt % 7 == 2) {
            printf("Thursday\n");
        }
        if (cnt % 7 == 3) {
            printf("Friday\n");
        }
        if (cnt % 7 == 4) {
            printf("Saturday\n");
        }
        if (cnt % 7 == 5) {
            printf("Sunday\n");
        }
        if (cnt % 7 == 6) {
            printf("Monday\n");
        }
        if (cnt % 7 == 0) {
            printf("Tuesday\n");
        }
    }
    return 0;
}

C++: #include <iostream>

void displayDate(int index) {
  int i = (7 + index - 1) % 7 ;

  if (i == 0) {
    std::cout << "Sunday" << std::endl;
  } else if (i == 1) {
    std::cout << "Monday" << std::endl;
  } else if (i == 2) {
    std::cout << "Tuesday" << std::endl;
  } else if (i == 3) {
    std::cout << "Wednesday" << std::endl;
  } else if (i == 4) {
    std::cout << "Thursday" << std::endl;
  } else if (i == 5) {
    std::cout << "Friday" << std::endl;
  } else if (i == 6) {
    std::cout << "Saturday" << std::endl;
  }
}

int main() {
  while (true) {
    int m, d;
    std::cin >> m;
    std::cin >> d;

    if (m == 0 && d == 0) {
      break;
    } else if (m == 1) {
      displayDate(d + 4);
    } else if (m == 2) {
      displayDate(d + 0);
    } else if (m == 3) {
      displayDate(d + 1);
    } else if (m == 4) {      
      displayDate(d + 4);
    } else if (m == 5) {
      displayDate(d + 6);
    } else if (m == 6) {
      displayDate(d + 2);
    } else if (m == 7) {
      displayDate(d + 4);
    } else if (m == 8) {
      displayDate(d + 0);
    } else if (m == 9) {
      displayDate(d + 3);
    } else if (m == 10) {
      displayDate(d + 5);
    } else if (m == 11) {
      displayDate(d + 1);
    } else if (m == 12) {
      displayDate(d + 3);
    }
  }

  return 0;
}

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

int main(void){
  int month[] = {31,29,31,30,31,30,31,31,30,31,30,31};
  string day[7] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", 
		   "Tuesday", "Wednesday"};

  int x, y, m, d, c;

  while(cin >> x >> y , x != 0){
    m = d = 1;
    c = 0;
    while(x !=m || y != d){
      d++;
      if(d > month[m - 1]){
	m++;
	d = 1;
      }
      c++;
      if(c == 7)
	c = 0;
      cout << ' ' << c << endl;
    }
  }

  return 0;
}

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 zeller(int y, int m, const int &d) {
  if (m == 1 || m == 2) y--, m += 12;
  int k = y % 100, j = y / 100;
  return (d + 13 * (m + 1) / 5 + k + k / 4 + j / 4 + 5 * j) % 7;
}

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

C++: #include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;

int main()
{
	int days[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30};
	const char* strs[] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday" };

	reep(i, 1, 12)
		days[i] += days[i-1];

	int m, d;
	while(scanf("%d%d", &m, &d), m&&d){
		puts(strs[(days[m-1]+d-1)%7]);
	}

	return 0;
}

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

class Days{
	string week;
public:
	Days() : week("Thursday"){}
	void calcDays(int,int);
	int monthToDays(int);
	void calcWeek(int);
	void setWeek(int);
	const string getWeek(void);
};

int Days::monthToDays(int month){
	if(month == 2)
		return 29;//うるう年
	if(month == 4 || month == 6 || month == 9 || month == 11)
		return 30;
	return 31;
}

void Days::calcDays(int month,int days){
	week = ("Thursday");//コンストラクタで初期化済みだが念のために
	int day = 0;//1月1日から何日経ったか
	for(int i = 1; i < month; i++){
		day += monthToDays(i);
	}
	day += (days - 1);
	calcWeek(day);
}

void Days::calcWeek(int day){
	setWeek(day %= 7);
}

const string Days::getWeek(void){
	return week;
}

void Days::setWeek(int day){
	switch(day){
	case 0:
		week = "Thursday";
		break;
	case 1:
		week = "Friday";
		break;
	case 2:
		week = "Saturday";
		break;
	case 3:
		week = "Sunday";
		break;
	case 4:
		week = "Monday";
		break;
	case 5:
		week = "Tuesday";
		break;
	case 6:
		week = "Wednesday";
		break;
	}
}

int main(){
	Days d;
	int month,day;
	while(1){
		cin >> month >> day;
		if(month == 0 || day == 0)
			break;
		d.calcDays(month,day);
		cout << d.getWeek() << endl;
	}
	return 0;
}