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++: #include <bits/stdc++.h>
using namespace std;
int main ()
{
    int m,d,r;

    while (1)
    {
        cin>>m>>d;
        if (m==0 || d==0)
            break;
        else
        {
            if (m==1)
                r=d;
            else if (m==2)
                r=31+d;
            else if (m==3)
                r=31+29+d;
            else if (m==4)
                r=31+29+31+d;
            else if (m==5)
                r=31+29+31+30+d;
            else if (m==6)
                r=31+29+31+30+31+d;
            else if (m==7)
                r=31+29+31+30+31+30+d;
            else if (m==8)
                r=31+29+31+30+31+30+31+d;
            else if (m==9)
                r=31+29+31+30+31+30+31+31+d;
            else if (m==10)
                r=31+29+31+30+31+30+31+31+30+d;
            else if (m==11)
                r=31+29+31+30+31+30+31+31+30+31+d;
            else if (m==12)
                r=31+29+31+30+31+30+31+31+30+31+30+d;
        }
        if (r%7==1)
            cout<<"Thursday"<<endl;
        else if (r%7==2)
            cout<<"Friday"<<endl;
        else if (r%7==3)
            cout<<"Saturday"<<endl;
        else if (r%7==4)
            cout<<"Sunday"<<endl;
        else if (r%7==5)
            cout<<"Monday"<<endl;
        else if (r%7==6)
            cout<<"Tuesday"<<endl;
        else if (r%7==0)
            cout<<"Wednesday"<<endl;
    }
}

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

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

const int month[] = {0, 31, 60, 91, 121, 152, 182, 212, 243, 273, 304, 334};
int main()
{
  int m, d, cntdays = 0;
  
  while (cin >> m >> d, m){
    cntdays = month[m - 1] + d;
    switch (cntdays % 7){
      case 0:
        cout << "Wednesday";
        break;
      case 1:
        cout << "Thursday";
        break;
      case 2:
        cout << "Friday";
        break;
      case 3:
        cout << "Saturday";
        break;
      case 4:
        cout << "Sunday";
        break;
      case 5:
        cout << "Monday";
        break;
      case 6:
        cout << "Tuesday";
        break;
    }
    cout << endl;
  }
}

C++: #include <iostream>
using namespace std;
int main(){
	int day[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
	int mon,d;
	while(cin>>mon>>d){
		int sum =0;
		if(mon == 0) break;
		for(int i=0;i<mon-1;i++){
			sum += day[i];
		}
		sum += d;
		int a = sum%7;
		if(a==1) cout<<"Thursday"<<endl;
		else if(a==2) cout<<"Friday"<<endl;
		else if(a==3) cout<<"Saturday"<<endl;
		else if(a==4) cout<<"Sunday"<<endl;
		else if(a==5) cout<<"Monday"<<endl;
		else if(a==6) cout<<"Tuesday"<<endl;
		else if(a==0) cout<<"Wednesday"<<endl;
	}
	return 0;
}

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

int n[12] = {31,29,31,30,31,30,31,31,30,31,30,31};

int totalday(int month, int day){
	int res = 0;
	for(int i=1; i<month; i++){
		res += n[i-1];
	}
	res += day;
	return res;
}

int main(void) {
	int month, day;
	while(cin >> month >> day){
		if(month==0 && day==0) break;
		int total = totalday(month, day);
		total = total % 7;

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

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

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

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int main() {
	int days[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	string week[] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};
	for(int month, day; cin >> month >> day && month && day;) {
		int sum = 0;
		rep(i,month - 1) {
			sum += days[i];
		}
		sum += day;
		sum %= 7;
		cout << week[sum] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

#define vcitr vector<int>::iterator
#define vcsitr vector<string>::iterator
#define mapcitr map<char, int>::iterator
#define mapsitr map<string, int>::iterator

typedef long long ll;

int iINF = 2147483647;
ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }

string day[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
int len[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
	int x, y;
	
	while (cin >> x >> y) {
		if (x==0 && y==0) break;
		
		int ans = 3;
		for_(i, 0, x) {
			int l = len[i];
			
			if (i==x-1) {
				l = y-1;
			}
			
			for_(j, 0, l) {
				ans++; ans %= 7;
			}
		}
		cout << day[ans] << endl;
	}
	
	return 0;
}

C++: #include<iostream>
using namespace std;
void daysel(int x){
  switch(x % 7){
  case 6:
  cout << "Tuesday"<<endl; break;
  case 7:
  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;
  }
}
void daycal(int month,int day){
  int x;
  switch(month){
  case 1:
  x = day; break;
  case 2:
  x = 31 + day; break;
  case 3:
  x = 60 + day; break;
  case 4:
  x = 91 + day; break;
  case 5:
  x = 121 + day; break;
  case 6:
  x = 152 + day; break;
  case 7:
  x = 182 + day; break;
  case 8:
  x = 213 + day; break;
  case 9: 
  x = 244 + day;break;
  case 10:
  x = 274 + day;break;
  case 11: 
  x = 305 + day; break;
  case 12:
  x = 335 + day; break;
  }
  daysel(x);

    }
int main(){
  int month,day;
  while(cin >> month >> day){
    if(month == 0&& day ==0){
      return 0;
    }
      daycal(month,day);
  }  
  
}