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<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main()
{
  int days[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

  int month, day;
  while(true)
  {
    cin >> month >> day;
    if(!month && !day)
      break;
    switch((days[month - 1] + day) % 7)
    {
    case 1:
      cout << "Thursday";
      break;
    case 2:
      cout << "Friday";
      break;
    case 3:
      cout << "Saturday";
      break;
    case 4:
        cout << "Sunday";
      break;
    case 5:
      cout << "Monday";
      break;
    case 6:
      cout << "Tuesday";
      break;
    case 0:
      cout << "Wednesday";
    }
    cout << endl;
  }

  return 0;
}

C++: #include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cstdio>
#include <cctype>
#include <queue>
#include <complex>
#include <climits>

typedef long long ll;

using namespace std;

int GetDayOfWeek(int nYear, int nMonth, int nDay)
{
	if (nMonth == 1 || nMonth == 2) {
		nYear--;
		nMonth += 12;
	}
	return (nYear + nYear / 4 - nYear / 100 + nYear / 400 + (13 * nMonth + 8) / 5 + nDay) % 7;
}


int main(){
	int a, b;
	while(cin >> a >> b){
		if(a == 0 && b == 0) break;
		string str;
		int s = GetDayOfWeek(2004, a, b);
		switch(s){
		case 0:
			str = "Sunday";
			break;
		case 1:
			str = "Monday";
			break;
		case 2:
			str = "Tuesday";
			break;
		case 3:
			str = "Wednesday";
			break;
		case 4:
			str = "Thursday";
			break;
		case 5:
			str = "Friday";
			break;
		case 6:
			str = "Saturday";
			break;
		}
	
	cout << str << endl;

	}

    return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<string.h>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;

int N;

int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };

int day = 0, month = 0;

void input(void) {
	CI day >> month;
	return;
}


int main(void) {
	int weekday = 0;
	int y = 2004;

	string dayname[] = { "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday" };
	while (true) {
		input();
		if (day == 0) {
			break;
		}
		if (month < 3) {
			y--; month += 12;
		}
		weekday =  (y + y / 4 - y / 100 + y / 400 + (13 * month + 8) / 5 + day) % 7;
		y = 2004;
		CO dayname[weekday] E
	}
	
	return 0;
}

C++: #include<string>
#include<vector>
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)


int main(){

	int a,b;
	while(true){

	cin >> a >> b;
	if(a==0 && b==0) break;

	vector<int>v;

	v.push_back(0);
	v.push_back(31);
	v.push_back(29);
	v.push_back(31);
	v.push_back(30);
	v.push_back(31);
	v.push_back(30);
	v.push_back(31);
	v.push_back(31);
	v.push_back(30);
	v.push_back(31);
	v.push_back(30);
	v.push_back(31);

	int d=b;
	rep(i,a) d+=v[i];

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

	}

	return 0;
}

C++: #include <stdio.h>

int main(void){
	int a,b;
	int day[]={0,31,29,31,30,31,30,31,31,30,31,30,31};

	while(scanf("%d %d",&a,&b),a){
		int youbi=0; // 0ismokuyou
		for(int i=1;i<a;i++) youbi=(youbi+day[i])%7;
		youbi=(youbi+b-1)%7;
		switch (youbi) {
			case 0:
				printf("Thursday\n");
				break;
			case 1:
				printf("Friday\n");
				break;
			case 2:
				printf("Saturday\n");
				break;
			case 3:
				printf("Sunday\n");
				break;
			case 4:
				printf("Monday\n");
				break;
			case 5:
				printf("Tuesday\n");
				break;
			case 6:
				printf("Wednesday\n");
				break;
		}
	}
	return 0;
}

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

int main() {
  int month,day;
  int md[] = { 31,29,31,30,31,30,31,31,30,31,30,31 };
  while ( cin >> month >> day, month || day ) {
    int total = 0;
    for ( int i = 0; i < month-1; i++ ) total += md[i];
    total += day;
    if ( total % 7 == 1 ) cout << "Thursday" << endl;
    else if ( total % 7 == 2 ) cout << "Friday" << endl;
    else if ( total % 7 == 3 ) cout << "Saturday" << endl;
    else if ( total % 7 == 4 ) cout << "Sunday" << endl;
    else if ( total % 7 == 5 ) cout << "Monday" << endl;
    else if ( total % 7 == 6 ) cout << "Tuesday" << endl;
    else if ( total % 7 == 0 ) cout << "Wednesday" << endl;
  }
  return 0;
}

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

int main(){

  int m, d, cnt, d1[12];
  int p[12] = {31, 29, 31, 30, 31, 30,
               31, 31, 30, 31, 30, 31};
  string str[7] = {"Monday", "Tuesday", "Wednesday",
                   "Thursday", "Friday", "Saturday",
                   "Sunday"};
  
  d1[0] = 3;
  for(int i=1; i<12; i++){
    d1[i] = (d1[i-1] + p[i-1]) % 7;
  }

  while(1){
    cin >> m >> d;
    if(m == 0 && d == 0){
      break;
    }
    cout << str[(d1[m-1] + d - 1) % 7] << endl;
  }

  return 0;

}