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<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000007
#define EPS 1E-12

string s[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
const int y = 2004;
int m, d;

int main()
{
  while((cin >> m >> d) && m){
    int D = (d + 26*(m+1)/10 + y + y/4 + -2*(y/100) + y/100/4 + 5) % 7;
    cout << s[D] << endl;
  }


  return 0;
}

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

class DayOfWeek {
	static const int m_startw = 4;

	int m_month;
	int m_day;

public:
	DayOfWeek( int mon, int day ):
		m_month( mon-1 ),
		m_day( day-1 )
	{}

	int days() const {
		static const int mdays[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };

		int d = m_day;
		for( int i = 0; i < m_month; ++i ) {
			d += mdays[i];
		}

		return d;
	}

	string name() const {
		static const string names[] = {
			"Sunday",
			"Monday",
			"Tuesday",
			"Wednesday",
			"Thursday",
			"Friday",
			"Saturday"
		};

		return names[(days() + m_startw) % 7];
	}
};

int main() {
	ios_base::sync_with_stdio( false );

	int m, d;
	while( cin >> m >> d ) {
		if( m == 0 ) { break; }

		cout << DayOfWeek( m, d ).name() << '\n';
	}
}

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

int count_day(int a){
  int i;
 
  switch(a){
  case 1:
    i = 0;
    break;
  case 2:
    i = 31;
    break;
  case 3:
    i = 60;
    break;
  case 4:
    i = 91;
    break;
  case 5:
    i = 121;
    break;
  case 6:
    i = 152;
    break;
  case 7:
    i = 183;
  case 8:
    i = 213;
    break;
  case 9:
    i = 244;
    break;
  case 10:
    i = 274;
    break;
  case 11:
    i = 305;
    break;
  case 12:
    i = 335;
  default:
    i = 0;
  }

  return i;
}


int main(){
  int month, day, convert_day;

  while(scanf("%d %d", &month, &day) != EOF){

    if(month == 0) break;

    convert_day = count_day(month);
    day = convert_day + day;

  switch(day % 7){ //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;
  default:
    break;
  }
  }


  return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
	
	int Md[12] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30}; 
	int month;
	int day;
		
	while( cin >> month >> day ) {
	
	if( month == 0 && day == 0)
	break;
	
	if( month == 1 && day == 1) {
		
	cout << "Thursday\n";
	continue;
	
	}
	if( month == 1 && day == 2) {
		
	cout << "Friday\n";
	continue;
	
	}
	if( month == 1 && day == 3) {
		
	cout << "Saturday\n";
	continue;
	
	}
	if( month == 1 && day == 4) {
		
	cout << "Sunday\n";
	continue;
	
	}
	for(int i=0;i<month;i++)
	day += Md[i];
	
	switch( (day - 4) % 7) {
		
		case 1:
		cout << "Monday\n";
		break;
		
		case 2:
		cout << "Tuesday\n";
		break;
		
		case 3:
		cout << "Wednesday\n";
		break;
		
		case 4:
		cout << "Thursday\n";
		break;
		
		case 5:
		cout << "Friday\n";
		break;
		
		case 6:
		cout << "Saturday\n";
		break;
		
		default:
		cout << "Sunday\n";
		break;
		
	}
	
	//cout << day; 
}
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
 
#define REP(i,b,n) for(int i=b;i<n;++i)
#define REPR(i,b,n) for(int i=n-1;i>=b;--i)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PI acos(-1.0)

using namespace std;

static const double EPS = 1e-9;
typedef pair<int, int> pii;
typedef long long ll;

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

int main(){
		
	int m, d;
	
	while(cin>>m>>d, (m||d)){
		
		int dsum = d+2;
		
		for(int i = 0; i < m; ++i){
			dsum += mday[i];
		}
		
		cout << week[dsum%7] << endl;
	}
	
	return 0;
}

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

int main() {
	int m, d,n;
	while (1) {
		cin >> m >> d;
		if (m == 0)
			break;
		n = d-1;
		switch (m) {
		case 12:
			n += 30;
		case 11:
			n += 31;
		case 10 :
			n += 30;
		case 9:
			n += 31;
		case 8:
			n += 31;
		case 7:
			n += 30;
		case 6:
			n += 31;
		case 5 :
			n += 30;
		case 4:
			n += 31;
		case 3:
			n += 29;
		case 2:
			n += 31;
		}
		switch (n % 7) {
		case 0:
			cout << "Thursday\n";
			break;
		case 1:
			cout << "Friday\n";
			break;
		case 2:
			cout << "Saturday\n";
			break;
		case 3:
			cout << "Sunday\n";
			break;
		case 4:
			cout << "Monday\n";
			break;
		case 5:
			cout << "Tuesday\n";
			break;
		case 6:
			cout << "Wednesday\n";
			break;
		}
	}
}

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