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>

using namespace std;

int main()
{
	int month[12];

	month[0]=31;
	month[1]=29;
	month[2]=31;
	month[3]=30;
	month[4]=31;
	month[5]=30;
	month[6]=31;
	month[7]=31;
	month[8]=30;
	month[9]=31;
	month[10]=30;
	month[11]=31;

	int hoge,fuga;

	hoge = 1;

	int i;
	int count=0;

	while(hoge!=0)
	{
		count = 0;
		cin >> hoge >> fuga;
		//cout << count << endl;
		for(i=0;i<hoge-1;i++)
		{
			count+=month[i];
		}	
		//cout << count << endl;

		count+=fuga;

		//cout << count << endl;

		int flag = 0;
	
		flag = count % 7;

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

C++: //#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <math.h>
#include<algorithm>
#include <utility>
using namespace std;
int main() {//Thursda,Friday...0,1,2,3,4,5,6
	int month,day, today;//31%7=3
	int add=0;
	while (1) {
		cin >> month >> today;
		if (month == 0) {
			break;
		}
		if (month == 1) {
			add = 0;
		}
		else {
			for (int i = 1; i < month; i++) {
				if (i == 2) {
					add+=1;
				}
				else if ((i % 2 == 0 && i < 8) ||i==9|| i == 11 ) {
					add += 2;
				}
				else {//31??\
					add += 3;
				}
			}
		}
		today += add;
		day = today%7;
		switch (day) {
		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;
		case 6:cout << "Tuesday" << endl; break;
		case 0:cout << "Wednesday" << endl; break;
		}
		add = 0;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

const int INF = 1e+9 * 2;
double eps = 1e-10;

string days[] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};
int main() {
	int m, d;
	while(cin >> m >> d && (m || d)){
		int cnt = 0;
		for(int i = 1; i <= 12; ++i){
			for(int j = 1; j <= 31; ++j){
				if(m == i && j == d){
					cout << days[cnt % 7] << endl;
					goto end;
				}
				cnt++; 
				if(i == 2 && j == 29)
					break;
				else if((i == 4 || i == 6 || i == 9 || i == 11) && j == 30)
					break;
			}
		}
		end:;
	}
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
	int a, b;
	while(1){
		cin >> a >> b;
		if(a == 0 && b == 0) break;
		int date[13][32];
		for(int i = 0;i < 13;i++){
			for(int j = 0;j < 32;j++){
				date[i][j] = 9;
			}
		}
		int count = 0;
		for(int i = 1;i < 13;i++){
			if(i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12){
				for(int j = 1;j < 32;j++){
					date[i][j] = count;
					count++;
					if(count == 7) count = 0;
					//cout << date[i][j];
				}
				//cout << endl;
			}
			else if(i == 4 || i == 6 || i == 9 || i == 11){
				for(int j = 1;j < 31;j++){
					date[i][j] = count;
					count++;
					if(count == 7) count = 0;
				}
			}
			else if(i == 2){
				for(int j = 1;j < 30;j++){
					date[i][j] = count;
					count++;
					if(count == 7) count = 0;
				}
			}

		}

		if(date[a][b] == 0) cout << "Thursday" << endl;
		if(date[a][b] == 1) cout << "Friday" << endl;
		if(date[a][b] == 2) cout << "Saturday" << endl;
		if(date[a][b] == 3) cout << "Sunday" << endl;
		if(date[a][b] == 4) cout << "Monday" << endl;
		if(date[a][b] == 5) cout << "Tuesday" << endl;
		if(date[a][b] == 6) cout << "Wednesday" << endl;

	}
	return 0;
}

C++: #include<stdio.h>
int main()
{
int p[12]={31,29,31,30,31,30,31,31,30,31,30,31};
int M,D,sum;
while(1)
{
sum=0;
scanf("%d %d",&M,&D);
if(M==0)break;
for(int i=0;i<M;i++)
sum+=p[i];

sum+=D;

switch(sum%7)
{
case 0:
printf("Sunday\n");break;
case 1:
printf("Monday\n");break;

case 2:
printf("Tuesday\n");break;

case 3:
printf("Wednesday\n");break;

case 4:
printf("Tursday\n");break;

case 5:
printf("Friday\n");break;

case 6:
printf("Saturday\n");break;
}
}
return 0;
}

C++: #include <iostream>

using namespace std;

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

        while (true) {
                cin >> mon >> day;
                if (!mon) {
                        break;
                }
                int sum = 0;
                for (int i = 0; i < mon - 1; i++) {
                        sum += d[i];
                }
                sum += day - 1;
                cout << ans[sum % 7] << endl;
        }


        return 0;
}

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

using namespace std;

string days[7] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};
int monthdays[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main()
{
  int day, month;
  while(1)
  {
    cin >> month >> day;
    if(!month)
      break;

    for(int i = 1; i < month; i++)
      day += monthdays[i];

    cout << days[day % 7] << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

const int mdays[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const char* days[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

int main(void) {
    int a, b, d;
    while (true) {
        cin >> a >> b;
        if (a == 0 && b == 0) break;
        d = 3;
        for (int m = 0; m < a - 1; m++) d += mdays[m];
        d += b - 1;
        cout << days[d % 7] << endl;
    }
    return 0;
}

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

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

int dd[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main()
{
  int m, d;
  while (cin >> m >> d) {
    if (m == 0 && d == 0)
      break;
    for (int i = 1; i < m; ++i)
      d += dd[i-1];
    cout << day[d%7] << endl;
  }
  return 0;
}