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++: #define _USE_MATH_DEFINES
#include <iostream>
#include <queue>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <cctype>
#include <cstdlib>
using namespace std;

#define INF (1 << 20)
#define EPS (1e-10)
#define EQ(a,b) (fabs((a)-(b)) < EPS)

int main(){
	int dn[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	string youbi[7] = {"Monday", "Tuesday", "Wednesday", "Thursday",
		"Friday", "Saturday", "Sunday"};
	int m, d;
	while (cin >> m >> d) {
		if (m == 0) break;
		int sum = 0;
		for (int i = 1; i < m; ++i) {
			sum += dn[i];
		}
		sum += d;
		cout << youbi[(sum + 2) % 7] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
int main(){
	int month,day;
	const int monthday[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	const std::string str[]={"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
	while(1){
		std::cin>>month>>day;
		if(month==0)break;
		int sum=day;
		for(int i=0;i<month;i++)sum+=monthday[i];
		std::cout<<str[sum%7-1]<<std::endl;
	}
	return 0;
	/*
	月曜日 Monday
	火曜日 Tuesday
	水曜日 Wednesday
	木曜日 Thursday
	金曜日 Friday
	土曜日 Saturday
	日曜日 Sunday
	*/
}

C++: #include <stdio.h>

int main(void)
{
	int day[13][32];
	int i, j;
	int n = 4;
	int month;
	int da;
	
	for (i = 1; i <= 12; i++){
		 if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12){
			for (j = 1; j <= 31; j++){
				day[i][j] = n;
				n++;
				if (n == 8){
					n = 1;
				}
			}
		}
		else if (i == 4 || i == 6 || i == 9 || i == 11){
			for (j = 1; j <= 30; j++){
				day[i][j] = n;
				n++;
				if (n == 8){
					n = 1;
				}
			}
		}
		else if (i == 2){
			for (j = 1; j <= 29; j++){
				day[i][j] = n;
				n++;
				if (n == 8){
					n = 1;
				}
			}
		}
	}
	
	while (1){
		
		scanf("%d %d", &month, &da);
		if (month == 0){
			return (0);
		}
		
		//printf("%d\n", day[month][da]);
		
		switch (day[month][da]){
			case 1:
			printf("Monday\n");
			break;
			
			case 2:
			printf("Tuesday\n");
			break;
			
			case 3:
			printf("Wednesday\n");
			break;
			
			case 4:
			printf("Thursday\n");
			break;
			
			case 5:
			printf("Friday\n");
			break;
			
			case 6:
			printf("Saturday\n");
			break;
			
			case 7:
			printf("Sunday\n");
			break;
		}
	}
}

C++: #include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>

using namespace std;

int ss[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
int day[13][32];

void cday(int m,int d,int dd){
	if(m==13)return;
	if(dd==8)dd=1;
	if(ss[m]==d-1)m++,d=1;
	day[m][d]=dd;
	cday(m,d+1,dd+1);
}

int main(void){
	cday(1,1,4);
	int a,b;
	while(1){
		cin >> a >> b;
		if(a==0)break;
		if(day[a][b]==1)cout << "Monday" << endl;
		if(day[a][b]==2)cout << "Tuesday" << endl;
		if(day[a][b]==3)cout << "Wednesday" << endl;
		if(day[a][b]==4)cout << "Thursday" << endl;
		if(day[a][b]==5)cout << "Friday" << endl;
		if(day[a][b]==6)cout << "Saturday" << endl;
		if(day[a][b]==7)cout << "Sunday" << endl;
	}
	return 0;
}

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

int search(int a){
	int month;
	if(a==2) month = 29;
	else if(a%2!=0) month = 31;
	else month = 30;
	return month;
}

char *Whatday(int a,int b){
	int month;
	char *day;
	int date=0;
	
	for(int i=1;i<a;i++){
		date = date+search(i);
	}
	date += b;
	switch(date%7){
		case 0: day ="Wednesdayday"; break;
		case 1: day ="Thursday"; break;
		case 2: day ="Friday"; break;
		case 3: day ="Saturday"; break; 
		case 4: day ="Sunday"; break;
		case 5: day ="Monday"; break;
		case 6: day ="Tuesday"; break;
	}
	return day;
}

int main() {
	int m,d;
	while(1){
		cin >> m >> d;
		if(m==0&&d==0) break;
		cout << Whatday(m,d) << 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%7]<<endl;

  }
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int m,d;
  while(cin>>m>>d,m+d){
    int day = 0;
    // 2 , 4 , 6 , 9 . 11 
    int month[12] = {31,29,31,30,31,30,
		     31,31,30,31,30,31};
    rep(i,m){
      day+=month[i];
    }
    day=(day + d + 3)%7;
    switch(day){
    case 0:
      cout<<"Thursday"<<endl;
      break;
    case 1:
      cout<<"Friday"<<endl;
      break;
    case 2:
      cout<<"Saturday"<<endl;
      break;
    case 3:
      cout<<"Sunday"<<endl;
      break;
    case 4:
      cout<<"Monday"<<endl;
      break;
    case 5:
      cout<<"Tuesday"<<endl;
      break;
    case 6:
      cout<<"Wednesday"<<endl;
      break;
    }
    

  }
}

C++: #define _USE_MATH_DEFINES
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main(){
	int hi[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	string youbi[7] = {"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};

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

		int ad = 0;
		for(int i=1;i<m;i++){
			ad+=hi[i-1];
		}
		cout << youbi[(ad+d-1)%7] << endl;
	}
	return 0;
}

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

string day[] = { "Thursday" , "Friday" , "Saturday" , "Sunday" , "Monday" , "Tuesday" , "Wednesday" } ;
int month[] = { 31,29,31,30,31,30,31,31,30,31,30,31 } ;
string calendar[13][32] = {} ;

int main(){
	
	int x , y , n=0 ;
	
	for( int i=0 ; i<12 ; i++ ){
		for( int j=0 ; j<=month[i] ; j++ ){
			calendar[i][j] = day[n%7] ;
			n++ ;
		}
		n-- ;
	}
	
	while(1){
		cin >> y >> x ;
		if( y==0 && x==0 ) break ;
		
		cout << calendar[y-1][x-1] << endl ;
	}
	
return 0 ;
}