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 date,month,day;
while(cin>>month>>date&&month!=0)
{	
switch(month)
{
case 1:
switch(date%7)
{
case 1:
day=4;
break;
case 2:
day=5;
break;
case 3:
day=6;
break;
case 4:
day=7;
break;
case 5:
day=1;
break;
case 6:
day=2;
break;
case 0:
day=3;
break;
}
break;
case 2:
switch(date%7)
{
case 1:
day=7;
break;
case 2:
day=1;
break;
case 3:
day=2;
break;
case 4:
day=3;
break;
case 5:
day=4;
break;
case 6:
day=5;
break;
case 0:
day=6;
break;
}
break;
case 3:
switch(date%7)
{
case 1:
day=1;
break;
case 2:
day=2;
break;
case 3:
day=3;
break;
case 4:
day=4;
break;
case 5:
day=5;
break;
case 6:
day=6;
break;
case 0:
day=7;
break;
}
break;
case 4:
switch(date%7)
{
case 1:
day=4;
break;
case 2:
day=5;
break;
case 3:
day=6;
break;
case 4:
day=7;
break;
case 5:
day=1;
break;
case 6:
day=2;
break;
case 0:
day=3;
break;
}
break;
case 5:
switch(date%7)
{
case 1:
day=6;
break;
case 2:
day=7;
break;
case 3:
day=1;
break;
case 4:
day=2;
break;
case 5:
day=3;
break;
case 6:
day=4;
break;
case 0:
day=5;
break;
}
break;
case 6:
switch(date%7)
{
case 1:
day=2;
break;
case 2:
day=3;
break;
case 3:
day=4;
break;
case 4:
day=5;
break;
case 5:
day=6;
break;
case 6:
day=7;
break;
case 0:
day=1;
break;
}
break;
case 7:
switch(date%7)
{
case 1:
day=4;
break;
case 2:
day=5;
break;
case 3:
day=6;
break;
case 4:
day=7;
break;
case 5:
day=1;
break;
case 6:
day=2;
break;
case 0:
day=3;
break;
}
break;
case 8:
switch(date%7)
{
case 1:
day=7;
break;
case 2:
day=1;
break;
case 3:
day=2;
break;
case 4:
day=3;
break;
case 5:
day=4;
break;
case 6:
day=5;
break;
case 0:
day=6;
break;
}
break;
case 9:
switch(date%7)
{
case 1:
day=3;
break;
case 2:
day=4;
break;
case 3:
day=5;
break;
case 4:
day=6;
break;
case 5:
day=7;
break;
case 6:
day=1;
break;
case 0:
day=2;
break;
}
break;
case 10:
switch(date%7)
{
case 1:
day=5;
break;
case 2:
day=6;
break;
case 3:
day=7;
break;
case 4:
day=1;
break;
case 5:
day=2;
break;
case 6:
day=3;
break;
case 0:
day=4;
break;
}
break;
case 11:
switch(date%7)
{
case 1:
day=1;
break;
case 2:
day=2;
break;
case 3:
day=3;
break;
case 4:
day=4;
break;
case 5:
day=5;
break;
case 6:
day=6;
break;
case 0:
day=7;
break;
}
break;
case 12:
switch(date%7)
{
case 1:
day=3;
break;
case 2:
day=4;
break;
case 3:
day=5;
break;
case 4:
day=6;
break;
case 5:
day=7;
break;
case 6:
day=1;
break;
case 0:
day=2;
break;
}
break;
}
switch(day)
{
case 1:
cout<<"Monday"<<endl;
break;
case 2:
cout<<"Tuesday"<<endl;
break;
case 3:
cout<<"Wednesday"<<endl;
break;
case 4:
cout<<"Thursday"<<endl; 
break;
case 5:
cout<<"Friday"<<endl;
break;
case 6:
cout<<"Saturday"<<endl;
break;
case 7:
cout<<"Sunday"<<endl;
break;
}
}
return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int day[12]={31,29,31,30,31,30,31,31,30,31,30,31};
  int m,d;
  int ans=0;
  while(cin>>m>>d){
    if(m==0&&d==0) break;
    ans = 0;
    for(int i=0;i<m-1;i++) ans += day[i];
    ans += d;
    switch(ans%7){
    case 0:
    cout << "Wednesday" << endl;
    break;
    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;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <array>
#include <numeric>
#include <cstdint>

int main()
{
	typedef std::array<std::uint16_t, 12> NumDays;
	NumDays const num_days = {
		0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30
	};
	typedef std::array<std::string, 7> WeekDay;
	WeekDay const days = {
		"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"
	};

	std::uint16_t m, d;
	for (std::cin >> m >> d; !(m == 0 && d == 0); std::cin >> m >> d) {
		std::uint16_t const num_spanned_days =
			d + std::accumulate(num_days.begin(), num_days.begin() + m, 0);
		std::cout << days[num_spanned_days % days.size()] << std::endl;
	}

	return 0;
}

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

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

int main(void){

	while (true){
		int m, d, days=0;
		cin>>m>>d;
		if (m==0) break;
		for (int i=0; i<m-1; i++){
			days += monthday[i];
		}
		int dif = days + d - 1;
		cout<<weekday[(dif+3)%7]<<endl;
	}
	return 0;
}

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

using namespace std;

int monthTable[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int date[13];
string dayTable[7] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};

void initialize(){
    date[0] = 0;
    date[1] = monthTable[1];
    for ( int i = 2; i <= 12; i++ ){
	date[i] = date[i-1] + monthTable[i];
    }
}

main(){
    initialize();
    int month, day;
    while( cin >> month >> day ){
	cout << dayTable[(date[month-1]+day-1)%7] << endl;
    }
}