Go: package main

import "fmt"

func main() {
	days := [12]int{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
	weekday := [7]string{"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}

	for {
		var m, d int
		fmt.Scan(&m, &d)
		if m == 0 {
			break
		}

		for i := 0; i < m-1; i++ {
			d += days[i]
		}

		fmt.Println(weekday[d%7])
	}
}

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int get_weekday(int y, int m, int d) {
    int n, tmp;
    if(m==1||m==2) {
        y--;
        m+=12;
    }
    tmp = y/100;
    n = (y+(y>>2)-tmp+(tmp>>2) + (13*m+8)/5+d)%7;
    return n;
}

int main()
{
    int a, b;
    while(true) {
        cin >> a >> b;
        if (a==0&&b==0) break;

        int n = get_weekday(2004, a, b);
        switch (n) {
            case 0:
                P("Sunday");
                break;
            case 1:
                P("Monday");
                break;
            case 2:
                P("Tuesday");
                break;
            case 3:
                P("Wednesday");
                break;
            case 4:
                P("Thursday");
                break;
            case 5:
                P("Friday");
                break;
            case 6:
                P("Saturday");
                break;
        }
    }
    return 0;
}

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

const int INF = 1e+9 * 2;
double eps = 1e-10;

string days[] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};
int main() {
	int m, d;
	while(cin >> m >> d && (m || d)){
		int cnt = 0;
		for(int i = 1; i <= 12; ++i){
			for(int j = 1; j <= 31; ++j){
				if(m == i && j == d){
					cout << days[cnt % 8] << endl;
					goto end;
				}
				cnt++; 
				if(i == 2 && j == 29)
					break;
				else if((i == 4 || i == 6 || i == 9 || i == 11) && j == 30)
					break;
			}
		}
		end:;
	}
	return 0;
}

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

int main()
{
	int day[365];
	int month[12] = {0,31,60,91,121,152,182,213,244,274,305,335};
	int m,d;
	
	for(int i=0;i<365;++i)
		day[i] = i%7;
	
	while(cin >> m >> d){
		if(!m)
			break;

		switch(day[month[m-1] + d-1]){
		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;
		}

	}
	return 0;
}

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

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

  while(cin >> m >> d, m || d){
    int sum = 2;
    for(int i = 1; i < m; i++){
      sum += day[i - 1];
    }
    sum += d;
    cout << s[sum % 7] << endl;
  }
}

C++: #include <iostream>
int main(void){
    int month,day,chek;
    while(std::cin >> month >> day,month){ int year = 2004;
    if(month == 1 || month == 2){year--;month+=12;}
    chek = ((year+ year/4-year/100+year/400+(13*month+8)/5+day)%7);
    switch (chek) {case 0:puts("Sunday");break; case 1:puts("Monday");break; case 2:puts("Tuesday");break; case 3:puts("Wednesday");break;
        case 4:puts("Thursday");break; case 5:puts("Friday");break; case 6:puts("Saturday");break; }}return 0;}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	string week[7] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
	int m,d,count_w, count_m;
	while(cin >> m >> d){
		if(m == 0) return 0;
		
		count_m = 1;
		count_w = 3;
		while(m != count_m){
			cout << "test" << endl;
			for(int i=1; i<=month[count_m-1]; i++, count_w++)
				if(m==count_m && d==i) break;
			count_m++;
		}
		cout << week[count_w%7] << endl;
	}
}

C++: #include <iostream>
using namespace std;
#define reep(i,f,n) for(int i=f;i<(int)n;++i)
#define rep(i,n) reep(i,0,n)
int d[13][32];
int main()
{
    d[1][1]=4;
    reep(i,2,32){
        if(d[1][i-1]!=7)d[1][i]=d[1][i-1]+1;
        else d[1][i]=1;
    }
    d[2][1]=d[1][31]+1;
    reep(i,2,30){
        if(d[2][i-1]!=7)d[2][i]=d[2][i-1]+1;
        else d[2][i]=1;
    }
    d[3][1]=d[2][29]+1;
    reep(i,2,32){
        if(d[3][i-1]!=7)d[3][i]=d[3][i-1]+1;
        else d[3][i]=1;
    }
    d[4][1]=d[3][31]+1;
    reep(i,2,31){
        if(d[4][i-1]!=7)d[4][i]=d[4][i-1]+1;
        else d[4][i]=1;
    }
    d[5][1]=d[4][30]+1;
    reep(i,2,32){
        if(d[5][i-1]!=7)d[5][i]=d[5][i-1]+1;
        else d[5][i]=1;
    }
    d[6][1]=d[5][31]+1;
    reep(i,2,31){
        if(d[6][i-1]!=7)d[6][i]=d[6][i-1]+1;
        else d[6][i]=1;
    }
    d[7][1]=d[6][30]+1;
    reep(i,2,32){
        if(d[7][i-1]!=7)d[7][i]=d[7][i-1]+1;
        else d[7][i]=1;
    }
    d[8][1]=d[7][31]+1;
    reep(i,2,32){
        if(d[8][i-1]!=7)d[8][i]=d[8][i-1]+1;
        else d[8][i]=1;
    }
    d[9][1]=d[8][31]+1;
    reep(i,2,31){
        if(d[9][i-1]!=7)d[9][i]=d[9][i-1]+1;
        else d[9][i]=1;
    }
    d[10][1]=d[9][30]+1;
    reep(i,2,32){
        if(d[10][i-1]!=7)d[10][i]=d[10][i-1]+1;
        else d[10][i]=1;
    }
    d[11][1]=d[10][31]+1;
    reep(i,2,30){
        if(d[11][i-1]!=7)d[11][i]=d[11][i-1]+1;
        else d[11][i]=1;
    }
    d[12][1]=d[11][30]+1;
    reep(i,2,32){
        if(d[12][i-1]!=7)d[12][i]=d[12][i-1]+1;
        else d[12][i]=1;
    }
    while(1)
    {
        int m,day;
        cin>>m>>day;if(!m)return 0;
        const char* str[10]={0,"Monday", "Tuesday", "Wednesday","Thursday", "Friday", "Saturday", "Sunday"};
        cout<<str[d[m][day]]<<endl;
    }
    return 0;
}