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<string>
using namespace std;

int m,d;
int data[] = {31,29,31,30,31,30,31,31,30,31,30,31};
string day[] = {"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};

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

		for(int i = 0; i < m - 1; i++){
			d+=data[m];
		}
		cout << day[d%7-1] << endl;
	}
}

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

int main(){
  int m, d;
  int t[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  string week[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

  while(cin >> m >> d, m || d){
    int sum = 0;

    for(int i = 0; i < m - 1; i++){
      sum += t[i];
    }
    sum += d;

    cout << week[(sum + 2) % 7] << endl;
  }
}

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

int main(){
  int day30[5] = {3,4,6,9,11};

  while(1) {
  int m,d;
  cin >> m >> d;
  if(m == 0 && d == 0) break;
  int a = 1,b = 1,count = 0;

  while(1) {

    if(a == m && b == d) break;
    
    b++;
    count++;

    if(a == 2 && b == 30) {
      a++;
      b = 1;
    }
    else if(b == 31) {
      for(int i=0;i<5;i++) 
	if(day30[i] == a) {
	  a++;
	  b = 1;
	  break;
	}
    }
    if( b == 32) {
      a++;
      b = 1;
    }
  }
  
  if(count % 7 == 4 ) cout <<"Monday"<<endl;
  else if(count % 7 == 5) cout << "Tuesday"<<endl;
  else if(count % 7 == 6) cout <<"Wednesday"<< endl;
  else if(count % 7 == 0) cout <<"Turseday"<< endl;
  else if(count % 7 ==1) cout << "Friday" << endl;
  else if(count % 7 ==2)cout << "Taturday" << endl;
  else if(count % 7 ==3) cout << "Sunday" << endl;
  
  }

  return 0;
}

C++: #include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

void print(int i){
	if(i==0)cout<<"Monday"<<endl;
	if(i==1)cout<<"Tuesday"<<endl;
	if(i==2)cout<<"Wednesday"<<endl;
	if(i==3)cout<<"Thursday"<<endl;
	if(i==4)cout<<"Friday"<<endl;
	if(i==5)cout<<"Saturday"<<endl;
	if(i==6)cout<<"Sunday"<<endl;
	return;
}

int main(){
	int m,d,num=3;
	int season[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	while(cin>>m>>d,m){
		rep(i,m-1)num+=season[i];
		num+=d-1;
		num%=7;
		print(num);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
void daysel(int x){
  switch(x % 7){
  case 6:
  cout << "Tuesday"<<endl; break;
  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;
  }
}
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 && !(month == 0 && day ==0)){   
      daycal(month,day);
  }  
  
}

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

using namespace std;

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

int main()
{
	int m,d;
	int day=0;
	while(1){
		scanf("%d %d",&m,&d);
		if(m==0&&d==0)break;
		day=0;
		for(int i=0;i<m-1;i++){
			day+=month[i];
		}
		day+=d;
		string result;
		const int r=day%7;
		switch(r){
			case 0:
			result="Wednesday";
			break;
		case 1:
			result="Thursday";
			break;
		case 2:
			result="Friday";
			break;
		case 3:
			result="Saturday";
			break;
		case 4:
			result="Sunday";
			break;
		case 5:
			result="Monday";
			break;
		case 6:
			result="Tuesday";
			break;
		}
		cout<<result<<"\n";
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

string date[7] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};

int main(){

    int year = 2004,month,day;

    while(cin >> month >> day){
    
        if(month == 0){
            return 0;
        }

        if(month == 1 || month==2){
            year--;
            month += 12;
        }
    
        int tmp = (year + year/4 - year/100 + year/400 + (13*month+8)/5 + day)%7;
    
        cout << date[tmp] << endl;
    }
    
    return 0;

}

C++:  
 #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int month[12]={31,29,31,30,31,30,31,31,30,31,30,31};
  
 int main()
 {
   int m,d;
   int duration=0;
   while(cin>>m>>d)
   {
     if(m==0&&d==0) break;
     else
     {
       if(m==1) duration=d-1;
       else 
       {
         for(int i=0;i<m-1;i++) duration+=month[i];
         duration+=(d-1);     
       }    
       if(duration%7==0) cout<<"Thursday"<<endl;
       else if(duration%7==1) cout<<"Friday"<<endl;
       else if(duration%7==2) cout<<"Saturday"<<endl;
       else if(duration%7==3) cout<<"Sunday"<<endl;
       else if(duration%7==4) cout<<"Monday"<<endl;
       else if(duration%7==5) cout<<"Tuesday"<<endl;
       else cout<<"Wednesday"<<endl;
     }                
   }
   //while(1);     
   return 0;  
 }

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

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

C++: //曜日を当てる
#include<cstdio>
#include<string>

using namespace std;

int main(void){
	string name[7]={"Mondey","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	int mond[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	int month,day,m,c;
	int i;	//ループカウンタ

	while(1){
		scanf("%d %d",&month,&day);
		if(month==0)break;
		m=1;	//月の始めの一月
		c=3;	//始まりは木曜日
		while(1){
			for(i=1;i<=mond[m-1];i++,c++)
				if(month==m && i==day) break;
			if(month==m && i==day) break;
			m++;
		}
		printf("%s\n",name[c%7].c_str());
	}

	return 0;
}