Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func zeller(month, day int) int {
	year := 2004
	if month == 1 || month == 2 {
		year--
		month += 12
	}
	return (year + year/4 - year/100 + year/400 + (13*month+8)/5 + day)%7
}

func main() {
	scanner.Split(bufio.ScanWords)
	for {
		month := nextInt()
		day := nextInt()
		if month == 0 && day == 0{
			break
		}
		switch zeller(month, day) {
		case 0:
			fmt.Println("Sunday")
		case 1:
			fmt.Println("Monday")
		case 2:
			fmt.Println("Tuesday")
		case 3:
			fmt.Println("Wednesday")
		case 4:
			fmt.Println("Thursday")
		case 5:
			fmt.Println("Friday")
		case 6:
			fmt.Println("Saturday")
		}
	}
}

C++: #include <iostream>
#include <string>
using namespace std;
int days[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string week[] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};

void solve()
{
	int m, d;
	while(cin >> m >> d, m || d)
	{
		int sum = 0;
		for(int i = 1; i < m; ++i)
		{
			sum += days[i - 1];
		}
		sum += d - 1;
		cout << week[sum % 7] << endl;
	}
}

int main()
{
	solve();
	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=3;
	while(cin>>m>>d,m||d){
		for(int i=1;i<m;++i)
			res+=month[i-1];
		res+=d-1;
		cout<<day[res%7]<<endl;
	}
	return 0;
}

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

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

int main()
{
	int m, d;
	while (cin >> m >> d, m)
	{
		int y = 2004;
		if (m < 3)
		{
			y--;
			m += 12;
		}

		int z = (y + y/4 - y/100 + y/400 + (13*m+8)/5 + d) % 7;
		cout << w[z] << endl;
	}
}

C++: /*AOJ 0027*/

#include<iostream>
using namespace std;

int main(){

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

	int sum = 0;

	int month=0,date = 0;

	while(cin>>month){
		cin>>date;

		if(month == 0){
			break;
		}
		sum = 0;

		for(int i=0;i<month;i++){
			if(month != i+1){
				sum+= day[i];
			}
		}
		sum += date;
		
		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{
			cout<<"Wednesday"<<endl;
		}
	}

	
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
 
int main()
{
    int days[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    string week[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
 
    for(;;){
        int month, day;
        cin >> month >> day;
        if(month == 0) return 0;
        int num = 0;
        for(int i=0; i<month-1; ++i)
            num += days[i];
        num += day; 
        cout << week[(num+2)%7] << endl;
    }
}

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

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

int main() {
	int y, m, d, c, h;
	while (cin >> m >> d, m) {
		y = 2004 - (m <= 2);
		m = m + 12 * (m <= 2);
		c = y / 100;
		y %= 100;
		h = d + (26 * (m + 1)) / 10 + y + y / 4 + 5 * c + c / 4;
		cout << day[h % 7] << endl;
	}
	return 0;
}

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

int main()
{
	int a, b, count = 0;
	int ans[100];
	while (cin >> a >> b) {
		if (a == 0)
			break;
		if (a == 1 || a == 4 || a == 7) {
			ans[count] = (b % 7 + 3)%7;
			if (ans[count] % 7 == 0)
				ans[count] = +7;
		}
		else if (a == 9 || a == 12) {
			ans[count] = (b % 7 + 2)%7;
			if (ans[count] % 7 == 0)
				ans[count] = +7;
		}
		else if (a == 2 || a == 8) {
			ans[count] = (b % 7 + 6)%7;
			if (ans[count] % 7 == 0)
				ans[count] = +7;
		}
		else if (a == 3 || a == 11) {
			ans[count] = b % 7;
			if (ans[count] % 7 == 0)
				ans[count]=+7;
		}
		else if (a == 5) {
			ans[count] = (b % 7 + 5)%7;
			if (ans[count] % 7 == 0)
				ans[count] = +7;
		}
		else if (a == 6) {
			ans[count] = (b % 7 + 1)%7;
			if (ans[count] % 7 == 0)
				ans[count] = +7;
		}
		else if (a == 10) {
			ans[count] = (b % 7 + 4)%7;
			if (ans[count] % 7 == 0)
				ans[count] = +7;
		}
		count++;
	}
	for (int i = 0; i < count; i++) {
		if (ans[i] == 1)
			cout << "Monday" << endl;
		else if (ans[i] == 2)
			cout << "Tuesday" << endl;
		else if (ans[i] == 3)
			cout << "Wednesday" << endl;
		else if (ans[i] == 4)
			cout << "Thursday" << endl;
		else if (ans[i] == 5)
			cout << "Friday" << endl;
		else if (ans[i] == 6)
			cout << "Saturday" << endl;
		else if (ans[i] == 7)
			cout << "Sunday" << endl;
	}
}

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

int main(){
  int m,d,x,i;

  while(1){
    cin>>m>>d;
    if(m==0&&d==0)break;
    x=0;
    for(i=1;i<m;i++){
      switch(i){
      case 1:
      case 3:
      case 5:
      case 7:
      case 8:
      case 10:
      case 12:
	x+=3;
	break;      
      case 2:
	x+=1;
	break;
      default:
	x+=2;
      }
    }
  switch((x+d-1)%7){
      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;
  }
  }  
  return 0;
}

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

using namespace std;

int main()
{
    int m, d;
    string day[] = {"Sunday", "Monday", 
                    "Tuesday", "Wednesday", "Thursday",
                    "Friday", "Saturday"};

    while (cin >> m >> d) {
        if (!m && !d)
            break;

        int year = 2004, h;
        if (m == 1 || m == 2) {
            year--;
            m += 12;
        }
        h = (year + year / 4 - year / 100 + year / 400 + (13 * m + 8) / 5 + d) % 7;
        
        cout << day[h] << endl;
    }

    return 0;
}

C++: #include<cstdio>

int day_date[12]={3,6,0,3,5,1,3,6,2,4,0,2};
int mon;
int day;

int main()
{
	while(true)
	{
		scanf("%d%d",&mon,&day);
		if(mon==0)break;
		int date=(day+day_date[mon-1]-1)%7;
		if(date==0) printf("Monday");
		if(date==1) printf("Tuesday");
		if(date==2) printf("Wednesday");
		if(date==3) printf("Thursday");
		if(date==4) printf("Friday");
		if(date==5) printf("Saturday");
		if(date==6) printf("Sunday");
		printf("\n");
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int a[13][32];
void day(void)
{
    int check=3;
    for(int i=1;i<13;i++){
        for(int j=1;j<32;j++){
            a[i][j]=check;
            check++;
            if(check==7)check=0;
            if((i==4||i==6||i==9||i==11)&&j==30)break;
            else if(i==2&&j==29)break;
        }
    }
}
int main()
{
    int mon,date;
    day();
    while(1){
        cin>>mon>>date;
        if(mon==0&&date==0)break;
        if(a[mon][date]==0)cout<<"Monday\n";
        else if(a[mon][date]==1)cout<<"Tuesday\n";
        else if(a[mon][date]==2)cout<<"Wednesday\n";
        else if(a[mon][date]==3)cout<<"Thrusday\n";
        else if(a[mon][date]==4)cout<<"Friday\n";
        else if(a[mon][date]==5)cout<<"Saturday\n";
        else cout<<"Sunday\n";
    }

}