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

int main() {
	char *weekday[7] = { "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday" };
	int monthdays[12] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30 };

	int m, d;
	while (cin >> m >> d, m) {
		int w = d-1;
		for (int i = 1; i < m; i++)
			w += monthdays[i];
		cout << weekday[w%7] << endl;
	}
	
	return 0;
}

C++: #include<iostream>
#include<string>
int main(){
	int month,day;
	int monthday[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	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 <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <climits>
#include <utility>

#define PRINT(STR) cout << STR << endl;
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define SPACE " "

typedef long long ll;

using namespace std;

int nextInt() { int n = -1; cin >> n; return n; }
double nextDouble() { double d = -1; cin >> d; return d; }
ll nextll() { ll n = -1; cin >> n; return n; }
string nextString() { string str; cin >> str; return str; }

int INF = 1LL << 25;
double EPS = 1e-9;

// BEGIN //////////////////////////////////////////////////////////////
int main() {
	const int months[13] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	const string answers[7] =
	{ "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday" };
	while (true) {
		int M = nextInt();
		int D = nextInt();
		if (M == 0) break;
		int past_days = 0;
		for (int i = 1; i < M; i++) {
			past_days += months[i];
		}
		past_days += D;
		PRINT(answers[past_days % 7 - 1]);
	}
	return 0;
}
// END   //////////////////////////////////////////////////////////////

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

using namespace std;

string today(int month, int day){
    string today;
    int startMonth=1, startDay=1, total=0;
    
    for(int i=startMonth; i<month; i++){
        switch(i){
            case 4:
            case 6:
            case 9:
            case 11:
                total += 30;
                break;
            
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                total += 31;
                break;
            case 2:
                total += 29;
                break;
        }
    }
    total += day;
    //cout << total%7 << endl;
    
    switch(total%7){
        case 1:
            today = "Thursday";
            break;
        case 2:
            today = "Friday";
            break;
        case 3:
            today = "Saturday";
            break;
        case 4:
            today = "Sunday";
            break;
        case 5:
            today = "Monday";
            break;
        case 6:
            today = "Tuesday";
            break;
        case 0:
            today = "Wednesday";
            break;
    }
    
    
    return today;
}


int main (int argc, char const* argv[]){
    int month, day, n;
    
    cin >> month >> day;
    while(month!=0 && day!=0){
        
        cout << today(month,day)<< endl;
        cin >> month >> day;
    }
    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<stdio.h>
int main(){
	int m,d,i;
	int W;
	int s=0;
	
	while(1){
		scanf("%d %d",&m,&d);
		if(m==0)break;
		for(i=1;i<m;i++){
			if(i==1 || i==3 || i==5 || i==7 || i==8 || i==10 || i==12)s+=31;
			else if(i==4 || i==6 || i==9 || i==11 )s+=30;
			else if(i==2)s+=29;
		}
		W=s+d;
		if(W%7==0)printf("Wednesay\n");
		else if(W%7==1)printf("Thursday\n");
		else if(W%7==2)printf("Friday\n");
		else if(W%7==3)printf("Saturday\n");
		else if(W%7==4)printf("Sunday\n");
		else if(W%7==5)printf("Monday\n");
		else if(W%7==6)printf("Tuesday\n");
	}
return 0;
}

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

int main(void){

    string day[7] = {"Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"};
    int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
    int x,y;

    while(cin >> x >> y){
        int h = 20;
        int n = 4;
        if(x == 0){
            break;
        }
        if(x == 1 || x == 2){
            n--;
            x+=12;
        }
                       
        int w = n + n/4 + h/4 - 2*h + 13*(x+1)/5 + y;
        //cout << w << endl;
       
        //cout << w%7 << endl;

        string ans = day[w%7];

        cout << ans << endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iostream>


using namespace std;

int main()
{
	int m, d;
	while (true)
	{
		scanf("%d %d", &m, &d);
		if (m == 0 && d == 0)
			break;

		int total = d;
		int dd[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
		for (int i = 1; i < m; ++i)
		{
			total += dd[i-1];
		}
		char* days[] = { "Monday", "Tuesday", "Wednesday", "Thursday",
			"Friday", "Saturday", "Sunday" };
		puts(days[(total+2)%7]);
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>

//#define PI 3.141592653589

using namespace std;


int m, d;
int nissuu[] = {31,29,31,30,31,30,31,31,30,31,30,31};
int sum;	//曜日を求める日までの通算日数

int main()
{
	while (1)
	{
		cin >> m >> d;
		if (m == 0) break;
		
		sum = 0;
		for (int i=0; i<m-1; i++)
		{
			sum += nissuu[i];
		}
		sum += d;
		//cout << "sum = " << sum << endl;
		if (sum % 7 == 1) cout << "Thursday" << endl;
		else if (sum % 7 == 2) cout << "Friday" << endl;
		else if (sum % 7 == 3) cout << "Saturday" << endl;
		else if (sum % 7 == 4) cout << "Sunday" << endl;
		else if (sum % 7 == 5) cout << "Monday" << endl;
		else if (sum % 7 == 6) cout << "Tuesday" << endl;
		else if (sum % 7 == 0) cout << "Wednesday" << endl;
	}
	
	return 0;
}