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 month[12]={0,3,4,0,2,5,0,3,6,1,4,6};
int main(){
  int m,d;
  while(cin >>m>>d,m||d){
    switch((d+month[m-1])%7){
    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;
    }
  }
  return 0;
}

C++: #include<stdio.h>
#include<string>
using namespace std;
int week(int x){
	x++;
	if(x==8)return 1;
	else return x;}
int main(){
	int d[13][32];
	int i,j,k=4;
	for(i=1;i<13;i++){
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
			for(j=1;j<32;j++){
				d[i][j]=k;
				k=week(k);}}
		if(i==2){
			for(j=1;j<30;j++){
				d[i][j]=k;
				k=week(k);}}
		if(i==4||i==6||i==9||i==11){
			for(j=1;j<31;j++){
				d[i][j]=k;
				k=week(k);}}}
	string day[8]={" ","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	int m,n;
	while(1){
		scanf("%d %d",&m,&n);
		if(m==0&&n==0)break;
		switch(d[m][n]){
			case 1:printf("Monday");break;
			case 2:printf("Tuesday");break;
			case 3:printf("Wednesday");break;
			case 4:printf("Thursday");break;
			case 5:printf("Friday");break;
			case 6:printf("Saturday");break;
			case 7:printf("Sunday");break;}
	printf("\n");}
	return 0;}

C++: #include<iostream>
using namespace std;
int main(){
	int mon,day,week;
	while(1){
		cin>>mon>>day;
		if(mon==0)break;
		switch(mon){
			case 1:
			mon=0;
			break;
			case 2:
			mon=31;
			break;
			case 3:
			mon=60;
			break;
			case 4:
			mon=91;
			break;
			case 5:
			mon=121;
			break;
			case 6:
			mon=152;
			break;
			case 7:
			mon=182;
			break;
			case 8:
			mon=213;
			break;
			case 9:
			mon=244;
			break;
			case 10:
			mon=274;
			break;
			case 11:
			mon=305;
			break;
			case 12:
			mon=335;
			break;
		}
		week=(mon+day)%7;
		switch(week){
		    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;
		}

C++: #include <bits/stdc++.h>
using namespace std;
const int days[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30};
const string s[] = {"Wednesday", "Thursday", "Friday", "Saturday",
                    "Sunday",    "Monday",   "Tuesday"};
int main() {
  int m, d;
  while (cin >> m >> d, m | d) {
    int sum = d;
    for (int i = 0; i < m - 1; i++) {
      sum += days[i];
    }
    cout << s[sum % 7] << endl;
  }
}

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

using namespace std;

int const Month[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
string const Week[7] = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };

int main(){
	int month, day;

	while (cin >> month >> day){
		if ((month == 0) && (day == 0)) break;
		int today = day;
		month--;
		while (month){
			today += Month[month - 1];
			month--;
		}
		cout << Week[(today + 2) % 7] << endl;
	}

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

C++: #include <vector>
#include <utility>
using namespace std;
typedef pair<int,int> MonthDay;
int main(){
  int monthnum[]={
    31,29,31,30,31,30,31,31,30,31,30,31
  };
  const string weekname[]={
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday",
    "Sunday"
  };
  vector<MonthDay> data;
  int month,day;
  while(cin>>month>>day){
    if(!month)break;
    data.push_back(MonthDay(month,day));
  }
  for(int i=0;i<data.size();i++){
    int daysum=0;
    for(int j=0;j<data[i].first-1;j++){
      daysum+=monthnum[j];
    }
    daysum+=data[i].second;
    int weekindex=(daysum+2)%7;
    cout<<weekname[weekindex]<<endl;
  }
}