Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
	"time"
)

var sc = bufio.NewScanner(os.Stdin)

//Sliceconvtoi ...
func Sliceconvtoi() []int {
	strs := strings.Split(sc.Text(), " ")

	var ints []int
	var x int

	for _, s := range strs {
		x, _ = strconv.Atoi(s)
		ints = append(ints, x)
	}

	return ints
}

func main() {
	for sc.Scan() {
		i := Sliceconvtoi()

		if i[0] == 0 && i[1] == 0 {
			break
		}

		m := time.Month(i[0])
		d := i[1]
		t := time.Date(2004, m, d, 0, 0, 0, 0, time.Local)
		fmt.Println(t.Weekday())
	}

}

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

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

int main()
{
	int month,day,tooshi;
	while(true)
	{
	cin >> month;
	cin >> day;
	if(month==0&&day==0)break;
	switch (month)
	{
		case 1:
		tooshi = day;
		break;
		case 2:
		tooshi = day+31;
		break;
		case 3:
		tooshi = day+60;
		break;
		case 4:
		tooshi = day+91;
		break;
		case 5:
		tooshi = day+121;
		break;
		case 6:
		tooshi = day+152;
		break;
		case 7:
		tooshi = day+182;
		break;
		case 8:
		tooshi = day+213;
		break;
		case 9:
		tooshi = day+244;
		break;
		case 10:
		tooshi = day+274;
		break;
		case 11:
		tooshi = day+305;
		break;
		case 12:
		tooshi = day+335;
		break;
	}

	switch (tooshi % 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;
}

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

int main(){
	int m, d;
	int days[12]={31,29,31,20,31,30,31,31,30,31,30,31};
	
	while( scanf(" %d %d", &m, &d)*m != 0 ){
		int i=0, c=0;
		while(i<=m-2){
			c+=days[i];
			++i;
		}
		c+=d;
	
		//printf("%d\n", c);
		if(c%7==1) printf("Thursday\n");
		else if(c%7==2) printf("Friday\n");
		else if(c%7==3) printf("Saturday\n");
		else if(c%7==4) printf("Sunday\n");
		else if(c%7==5) printf("Monday\n");
		else if(c%7==6) printf("Tuesday\n");
		else if(c%7==0) printf("Wednesday\n");
	}

	return 0;
}

C++: #include<stdio.h>
int main()
{
int p[12]={31,29,31,30,31,30,31,31,30,31,30,31};
int M,D,sum;
while(1)
{
sum=0;
scanf("%d %d",&M,&D);
if(M==0)break;
for(int i=0;i<M;i++);
sum+=p[i];

sum+=D;

switch(sum%d)
{
case 0:
printf("Sunday\n");
case 1:
printf("Monday\n");

case 2:
printf("Tuesday\n");

case 3:
printf("Wednesday\n");

case 4:
printf("Tursday\n");

case 5:
printf("Friday\n");

case 6:
printf("Saturday\n");
}
}
return 0;
}

C++: #include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

vector<string> weeks = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
int month[] = {31,29,31,30,31,30,31,31,30,31,30,31};
int mm,dd;
void solve() {
    int day = 2;
    for(int i=1;i<mm;i++) day += month[i-1];
    day += dd;
    day %= 7;
    cout<<weeks[day]<<endl;

}
int main() {
    while(cin>>mm>>dd) {
        if(mm+dd==0) break;
        solve();
    }
    return 0;
}