Go: package main

import (
        "fmt"
)

func main() {
        var weeks = []string{"Thursday",
                "Friday",
                "Saturday",
                "Sunday",
                "Monday",
                "Tuesday",
                "Wednesday"}

        for {
                var m, d int
                _, err := fmt.Scanf("%d %d", &m, &d)
                if err != nil || m + d == 0 {
                        break
                }
                var days int

                for {
                        lm, ld := getLastDay(m, d)
                        if lm + ld == 0 {
                                break
                        }
                        days++
                        m = lm
                        d = ld
                }
                fmt.Println(weeks[days%7])
        }
}

func getLastDay(m int, d int) (lm int, ld int) {
        if m == 1 && d == 1 {
                return 0, 0
        }

        if d > 1 {
                return m, d-1
        } else {
                if m == 3 {
                        return m-1, 29
                }
                if m == 3 || m == 5 || m == 7 || m == 10 || m == 12 {
                        return m-1, 30
                } else {
                        return m-1, 31
                }
        }
}

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