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<stdio.h>
#include<string>
using namespace std;
int week(int x){
	x++;
	if(x==8)return 1;
	else return x;}
int main(){
	int d[13][32];
	int i,j,k=4;
	for(i=1;i<13;i++){
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
			for(j=1;j<32;j++){
				d[i][j]=k;
				k=week(k);}}
		if(i==2){
			for(j=1;j<30;j++){
				d[i][j]=k;
				k=week(k);}}
		if(i==4||i==6||i==9||i==11){
			for(j=1;j<31;j++){
				d[i][j]=k;
				k=week(k);}}}
	string day[8]={" ","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	int m,n;
	while(1){
		scanf("%d %d",&m,&n);
		if(m==0&&n==0)break;
		switch(d[m][n]){
			case 1:printf("Monday");break;
			case 2:printf("Tuesday");break;
			case 3:printf("Wednesday");break;
			case 4:printf("Thursday");break;
			case 5:printf("Friday");break;
			case 6:printf("Saturday");break;
			case 7:printf("Sunday");break;}
	printf("\n");}
	return 0;}

C++: #include<iostream>
using namespace std;
int main(){
	int mon,day,week;
	while(1){
		cin>>mon>>day;
		if(mon==0)break;
		switch(mon){
			case 1:
			mon=0;
			break;
			case 2:
			mon=31;
			break;
			case 3:
			mon=60;
			break;
			case 4:
			mon=91;
			break;
			case 5:
			mon=121;
			break;
			case 6:
			mon=152;
			break;
			case 7:
			mon=182;
			break;
			case 8:
			mon=213;
			break;
			case 9:
			mon=244;
			break;
			case 10:
			mon=274;
			break;
			case 11:
			mon=305;
			break;
			case 12:
			mon=335;
			break;
		}
		week=(mon+day)%7;
		switch(week){
		    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;
		}

C++: #include <bits/stdc++.h>
using namespace std;
const int days[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30};
const string s[] = {"Wednesday", "Thursday", "Friday", "Saturday",
                    "Sunday",    "Monday",   "Tuesday"};
int main() {
  int m, d;
  while (cin >> m >> d, m | d) {
    int sum = d;
    for (int i = 0; i < m - 1; i++) {
      sum += days[i];
    }
    cout << s[sum % 7] << endl;
  }
}

C++: #include<iostream>
#include<string>

using namespace std;

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

int main(){
	int month, day;

	while (cin >> month >> day){
		if ((month == 0) && (day == 0)) break;
		int today = day;
		month--;
		while (month){
			today += Month[month - 1];
			month--;
		}
		cout << Week[(today + 2) % 7] << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
	const string day[]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	const int month[]={31,29,31,30,31,30,31,31,30,31,30,31};
	int m,d,res=2;
	while(cin>>m>>d,m||d){
		for(int i=1;i<m;++i)
			res+=month[i]+1;
		res+=d;
		cout<<day[res%7]<<endl;
	}
	return 0;
}

C++: #include <vector>
#include <utility>
using namespace std;
typedef pair<int,int> MonthDay;
int main(){
  int monthnum[]={
    31,29,31,30,31,30,31,31,30,31,30,31
  };
  const string weekname[]={
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday",
    "Sunday"
  };
  vector<MonthDay> data;
  int month,day;
  while(cin>>month>>day){
    if(!month)break;
    data.push_back(MonthDay(month,day));
  }
  for(int i=0;i<data.size();i++){
    int daysum=0;
    for(int j=0;j<data[i].first-1;j++){
      daysum+=monthnum[j];
    }
    daysum+=data[i].second;
    int weekindex=(daysum+2)%7;
    cout<<weekname[weekindex]<<endl;
  }
}

C++: #include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int a, b;
int d[] = {31,29,31,30,31,30,31,31,30,31,30,31};
string s[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

signed main() {
	while (1) {
		cin >> a >> b;
		if (a==0) break;
		cout << s[accumulate(d,d+a-1,b+2)%7] << endl;
	}
}

C++: 
#include <iostream>

using namespace std;

const int days[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const char *daynames[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

int main() {
    while(true) {
        int m, d;
        cin >> m >> d;
        if(!m && !d) break;

        int daycnt = 0;
        for(int i = 1; i < m; ++i) daycnt += days[i];
        daycnt += d;
        cout << daynames[(daycnt+2) % 7] << endl;
    }
    return 0;
}

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

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++) d+=mon[i];

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