Go: package main

import (
        "fmt"
)

func main() {
        var weeks = []string{"Thursday",
                "Friday",
                "Saturday",
                "Sunday",
                "Monday",
                "Tuesday",
                "Wednesday"}

        for {
                var m, d int
                _, err := fmt.Scanf("%d %d", &m, &d)
                if err != nil || m + d == 0 {
                        break
                }
                var days int

                for {
                        lm, ld := getLastDay(m, d)
                        if lm + ld == 0 {
                                break
                        }
                        days++
                        m = lm
                        d = ld
                }
                fmt.Println(weeks[days%7])
        }
}

func getLastDay(m int, d int) (lm int, ld int) {
        if m == 1 && d == 1 {
                return 0, 0
        }

        if d > 1 {
                return m, d-1
        } else {
                if m == 3 {
                        return m-1, 29
                }
                if m == 3 || m == 5 || m == 7 || m == 10 || m == 12 {
                        return m-1, 30
                } else {
                        return m-1, 31
                }
        }
}

C++: #include<iostream>
#include<string>
using namespace std;
int sum_of_days(int m, int d){
  int sum = 0;
  int mon[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,};
  for(int i = 0; i < m; i++) sum += mon[i];
  return sum + d - 1;
}
string what_day(int s){
  string day[] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};
  return day[s % 7];
}
int main(){
  int m, d;
  while(cin >> m >> d, !(m==0 && d==0)){
    cout << what_day(sum_of_days(m, d)) << endl;
  }
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a[20][50]={{0}};
    int i=4;
    int x,y;
    for(int k=1;k<=31;k++)
    {
        a[1][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=29;k++)
    {
        a[2][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=31;k++)
    {
        a[3][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=30;k++)
    {
        a[4][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=31;k++)
    {
        a[5][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=30;k++)
    {
        a[6][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=31;k++)
    {
        a[7][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=31;k++)
    {
        a[8][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=30;k++)
    {
        a[9][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int g=1;g<=31;g++)
    {
        a[10][g]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=30;k++)
    {
        a[11][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=31;k++)
    {
        a[12][k]=i;
        i++;
        if(i==8)i=1;
    }
    //for(int bb=1;bb<=12;bb++)
    //{
    //    for(int aa=1;aa<32;aa++)
    //   {
    //        printf("a[%d][%d]=%d\n",bb,aa,a[bb][aa]);
    //    }
    //}
    while(cin>>x>>y)
    {
        if(x==0)break;
        if(a[x][y]==1)cout<<"Monday"<<endl;
        if(a[x][y]==2)cout<<"Tuesday"<<endl;
        if(a[x][y]==3)cout<<"Wednesday"<<endl;
        if(a[x][y]==4)cout<<"Thursday"<<endl;
        if(a[x][y]==5)cout<<"Friday"<<endl;
        if(a[x][y]==6)cout<<"Saturday"<<endl;
        if(a[x][y]==7)cout<<"Sunday"<<endl;
    }
    return 0;
}

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;
	}
}