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++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const LL INF = 1e18;

int month[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
string yobi[]={"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
int main(){
	int mm,dd;
	while(cin>>mm>>dd){
		if(mm==0&&dd==0)break;
		int day=0;
		for(int i=1;i<=12;i++){
			if(mm==i){
				day+=dd-1;
				break;
			}
			day+=month[i];
		}
		cout<<yobi[day%7]<<endl;
	}
	return 0;
}
/*

*/

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


int main(){

	int m,d,n,J,K;
	J=20;
	K=4;
	
	
	while (1) {
		cin>>m>>d;
		if (m==0) break;
		if (m==1||m==2) 
			n=(d+((m+12+1)*26)/10+(K-1)+(K-1)/4+J/4+5*J) %7;
		else
			n=(d+((m+1)*26)/10+K+K/4+J/4+5*J) %7;
		
		switch (n) {
			case 0:
				cout << "Saturday" <<endl;
				break;
			case 1:
				cout << "Sunday" <<endl;
				break;
			case 2:
				cout << "Monday" <<endl;
				break;
			case 3:
				cout << "Tuesday" <<endl;
				break;
			case 4:
				cout << "Wednesday" <<endl;
				break;
			case 5:
				cout << "Thursday" <<endl;
				break;
			case 6:
				cout << "Friday" <<endl;
				break;
			default :
				break;
		}
		
	}
		
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <algorithm>
#include <cctype>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);

int x,y,tu[11]={31,29,31,30,31,30,31,31,30,31,30};

int main(){
	while(1){
		cin>>x>>y;
		if(!x&&!y) break;
		int num=0;
		for(int i=0;i<x-1;i++) num+=tu[i];
		num+=y;
		int ans=num%7;
		if(ans==1) cout<<"Thursday"<<endl;
		else if(ans==2) cout<<"Friday"<<endl;
		else if(ans==3) cout<<"Saturday"<<endl;
		else if(ans==4) cout<<"Sunday"<<endl;
		else if(ans==5) cout<<"Monday"<<endl;
		else if(ans==6) cout<<"Tuesday"<<endl;
		else if(!ans) cout<<"Wednesday"<<endl;
	}
}

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

int main(){
  int m, d;
  int days[]={0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366};

  while(cin>>m>>d){
    if(m==0) break;
    d+=days[m-1];
    d%=7;
    switch(d){
    case 0: printf("Wednesday\n"); break;
    case 1: printf("Thursday\n"); break;
    case 2: printf("Friday\n"); break;
    case 3: printf("Saturday\n"); break;
    case 4: printf("Sunday\n"); break;
    case 5: printf("Monday\n"); break;
    case 6: printf("Tuesday\n");
    }
  }

  return 0;
}

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

using namespace std;

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

int main() {
  int k,m,d;
  string today[7]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
  int mon[12]={31,29,31,30,31,30,31,31,30,31,30,31};

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

    for(int i=0;m-1>i;i++){

      if(m==1)break;
      else d+=mon[i];

  }
    k=d%7+2;
    cout <<today[k]<<endl;
  
  }
}

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

int main() {
	int mth[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	char wks[][16]={"Wednesday","Thursday","Friday","Saturday","Sunday",
				"Monday","Tuesday"};
	int m,d;
	while(cin>>m>>d,m){
		int days=0;
		for(int i=1;i<m;i++) days+=mth[i];
		days+=d; cout<<wks[days%7]<<endl;
	}
}

C++: #include <iostream>

using namespace std;
#define rep2(x,from,to) for(int x=(from); x<(to); (x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	int m, d;
	int c[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	while(cin >> m >> d && (m || d)) {
		int total = 0;
		rep(i,m-1) {
			total += c[i];
		}
		total += d;
		switch(total % 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;
		}
	}
	return 0;
}