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

using namespace std;
string a[7] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
int main(void){
  int aa,b;
  int mon[12] = {31,28,
		 31,30,
		 31,30,
		 31,31,
		 30,31,
		 30,31};
  while(cin>>aa>>b,aa+b){
    int d = b;
    for(int i = 0 ; i < aa-1 ; i ++){
      d += mon[i];
      cout<<d<<endl;
    }

    cout<<a[(d+2)%7]<<endl;
  }
  //*/
}

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

int main(){
	int m,d;
	while(true){
		cin >> m >> d;
		if(m == 0)break;
		int M = 1,D = 1;
		for(int i = 0; i < 366; i++){
			if(M == m && D == d){
				if(i % 7 == 0)cout << "Thursday" << endl;
				if(i % 7 == 1)cout << "Friday" << endl;
				if(i % 7 == 2)cout << "Saturday" << endl;
				if(i % 7 == 3)cout << "Sunday" << endl;
				if(i % 7 == 4)cout << "Monday" << endl;
				if(i % 7 == 5)cout << "Tuesday" << endl;
				if(i % 7 == 6)cout << "Wednesday" << endl;
			}
			D++;
			if((M == 1 || M == 3 || M == 5 || M == 7 || M == 8 || M == 10 || M == 12) && (D == 32)){
				M++;
				D = 1;
			}
			if((M == 4 || M == 6 || M == 9 || M == 11) && (D == 31)){
				M++;
				D = 1;
			}
			if(M == 2 && D == 30){
				M++;
				D = 1;
			}
		}
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

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

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

int main() {
  int m, d;
  string day;
  while(1) {
    cin >> m >> d;
    if (m == 0) break;
    for (int i = 0; i < m - 1; i++)
      d += DAYS_NUM[i];
    d = (d + 2) % 7;
    cout << days[d] << endl;
  }
  return 0;
}

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

int main(){
  int M[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  string w[7] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};

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

    int tmp = d;
    for(int i=0; i<m; i++) tmp += M[i];

    cerr << tmp << endl;
    cout << w[tmp%7] << endl;
  }

  return 0;
}

C++: #include <stdio.h>

static int days[] = {
  0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30
};

static char* week[] = {
  "Monday",
  "Tuesday",
  "Wednesday",
  "Thursday",
  "Friday",
  "Saturday",
  "Sunday"
};

int main(void)
{
  int i;
  for (i=0; i<11; ++i) {
    days[i+1] += days[i];
  }

  int month, day;
  while (scanf("%d %d", &month, &day) != EOF) {
    if (month==0 && day==0) {
      break;
    }

    day += days[month-1];
    day += 2;
    day %= 7;

    printf("%s\n", week[day]);
  }
  return 0;
}