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 <vector>
#include <string>

using namespace std;

int main(int argc, char *argv[]) {
  vector<string> result;
  int m, d;
  int mday[12] = {31, 29, 31, 30, 31, 30,
                  31, 31, 30, 31, 30, 31};

  while (true) {
    cin >> m >> d;
    if (m == 0 && d == 0)
      break;
    int days = 0;
    for (int i = 1; i < m; i++)
      days += mday[i-1];
    days += d;
    days %= 7;
    if (days == 1)
      result.push_back("Thursday");
    else if (days == 2)
      result.push_back("Friday");
    else if (days == 3)
      result.push_back("Saturday");
    else if (days == 4)
      result.push_back("Sunday");
    else if (days == 5)
      result.push_back("Monday");
    else if (days == 6)
      result.push_back("Tuesday");
    else
      result.push_back("Wednesday");
  }

  for (int i = 0; i < result.size(); i++)
    cout << result[i] << endl;
  return 0;
}

C++: #include <iostream>

using namespace std;


int totalDate(int month, int date)
{
	static const int MONTH[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

	int sum = 0;
	for(int i = 0; i < month-1; i++)
		sum += MONTH[i];

	return sum + date;
}

const char* day(int total_date)
{
	static const char* DAY[] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};

	return DAY[(total_date-1)%7];
}

int main()
{
	while(true)
	{
		int month, date;
		cin >> month >> date;

		if(month == 0)
			break;

		cout << day(totalDate(month, date)) << endl;
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
#include<cstdio>
int main(){
  int year[12]={31,29,31,30,31,30,31,31,30,31,30,31};
  int month,day,ans;
  while(1){
    cin>>month>>day;
    if(!month && !day)break;
    ans=0;
    for(int i=1;i<month;i++){
      ans+=year[i-1];
    }
    ans+=day;
    switch (ans%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;
    }
  }
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,n) for(long long int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long ll;
typedef vector<long long int> vi;
typedef vector<long long int>::iterator vit;

int main(){
	int m, d, c = 0;
	bool f = 0;
	int a[13] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	while (cin >> m >> d){
		if (m == 0)break;
		for (int i = 0; i < m; i++){
			for (int j = 0; j < a[i]; j++){
				c++;
				if (i == m - 1 && j == d - 1){
					f = 1;
					break;
				}
			}
			if (f)break;
		}
		c = c % 7;
		if (c == 1){
			cout << "Thursday\n";
		}
		else if (c == 2){
			cout << "Friday\n";
		}
		else if (c == 3){
			cout << "Saturday\n";
		}
		else if (c == 4){
			cout << "Sunday\n";
		}
		else if (c == 5){
			cout << "Monday\n";
		}
		else if (c == 6){
			cout << "Tuesday\n";
		}
		else {
			cout << "Wednesday\n";
		}
		c = 0;
		f = 0;
	}
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

const int days[12] = {
  31,29,31,30,
  31,30,31,31,
  30,31,30,31
};

const char *date[7] = {
  "Monday",
  "Tuesday",
  "Wednesday",
  "Thursday",
  "Friday",
  "Saturday",
  "Sunday"
};

int ans[12][31];

int main(){
  int d = 3;
  REP(i,12){
    REP(j,days[i]){
      ans[i][j] = (d++)%7;
    }
  }
  int a,b;
  while(cin>>a>>b,a)
    cout << date[ans[a-1][b-1]] << endl;

  return 0;
}

C++: #define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<list>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

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

int b[13] = { 0,31,29,31,30,31,30,31,31,30,31,30,31 };

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

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

int main()
{
  int m, d;
  while (1){
    cin >> m >> d;
    if (m == 0){
      break;
    }
    if (m == 2){
      d += 31;
    }
    if (m == 3){
      d += 60;
    }
    if (m == 4){
      d += 91;
    }
    if (m == 5){
      d += 121;
    }
    if (m == 6){
      d += 152; 
    }
    if (m == 7){
      d += 182;
    }
    if (m == 8){
      d += 213;
    }
    if (m == 9){
      d += 244;
    }
    if (m == 10){
      d += 274;
    }
    if (m == 11){
      d += 305;
    }
    if (m == 12){
      d += 335;
    }

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

  return 0;
}

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;

	cin >> hoge >> fuga;

	int i;
	int count=0;

	if(hoge!=0)
	{
		for(i=0;i<hoge-1;i++)
		{
			count+=month[i];
		}	
		
		count+=fuga;

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