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 <bits/stdc++.h>
using namespace std;

int main(){
	int m,d,ans,i,tmp = 0;
	while(cin>>m>>d,m != 0){
		ans = 0;
		tmp = 0;
		for(i = m-1;i != 0;i--){
			switch(i){
				case 1:
				case 3:
				case 5:
				case 7:
				case 8:
				case 10:
			{
				tmp += 31;
				break;
			}
				case 4:
				case 6:
				case 9:
				case 11:
			{
				tmp += 30;
				break;
			}
				case 2:
			{
				tmp += 29;
				break;
			}
			}
		}
		cout<<tmp<<endl;
		tmp += d;
		ans = tmp % 7;
		switch(ans){
			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>
using namespace std;

int main(){
  int m,d;
  int cnt;
  string days[7]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
  while(1){
    cnt = 0;
    cin >> m >> d;
    if(m == 0 && d == 0) break;
    cnt += d;
    for(m--;m>0;m--){
      switch (m){
      case 4:
      case 6:
      case 9:
      case 11:
	cnt += 30;
	break;
      case 2:
	cnt += 29;
	break;
      default:
	cnt += 31;
	break;
      }
    }
    cout << days[cnt%7] << endl;
  }
}

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