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;
#define reep(i,f,n) for(int i=f;i<(int)n;++i)
#define rep(i,n) reep(i,0,n)
int d[13][32];
int main()
{
    d[1][1]=4;
    reep(i,2,32){
        if(d[1][i-1]!=7)d[1][i]=d[1][i-1]+1;
        else d[1][i]=1;
    }
    d[2][1]=d[1][31]+1;
    reep(i,2,30){
        if(d[2][i-1]!=7)d[2][i]=d[2][i-1]+1;
        else d[2][i]=1;
    }
    d[3][1]=d[2][29]+1;
    reep(i,2,32){
        if(d[3][i-1]!=7)d[3][i]=d[3][i-1]+1;
        else d[3][i]=1;
    }
    d[4][1]=d[3][31]+1;
    reep(i,2,31){
        if(d[4][i-1]!=7)d[4][i]=d[4][i-1]+1;
        else d[4][i]=1;
    }
    d[5][1]=d[4][30]+1;
    reep(i,2,32){
        if(d[5][i-1]!=7)d[5][i]=d[5][i-1]+1;
        else d[5][i]=1;
    }
    d[6][1]=d[5][31]+1;
    reep(i,2,31){
        if(d[6][i-1]!=7)d[6][i]=d[6][i-1]+1;
        else d[6][i]=1;
    }
    d[7][1]=d[6][30]+1;
    reep(i,2,32){
        if(d[7][i-1]!=7)d[7][i]=d[7][i-1]+1;
        else d[7][i]=1;
    }
    d[8][1]=d[7][31]+1;
    reep(i,2,32){
        if(d[8][i-1]!=7)d[8][i]=d[8][i-1]+1;
        else d[8][i]=1;
    }
    d[9][1]=d[8][31]+1;
    reep(i,2,31){
        if(d[9][i-1]!=7)d[9][i]=d[9][i-1]+1;
        else d[9][i]=1;
    }
    d[10][1]=d[9][30]+1;
    reep(i,2,32){
        if(d[10][i-1]!=7)d[10][i]=d[10][i-1]+1;
        else d[10][i]=1;
    }
    d[11][1]=d[10][31]+1;
    reep(i,2,30){
        if(d[11][i-1]!=7)d[11][i]=d[11][i-1]+1;
        else d[11][i]=1;
    }
    d[12][1]=d[11][30]+1;
    reep(i,2,32){
        if(d[12][i-1]!=7)d[12][i]=d[12][i-1]+1;
        else d[12][i]=1;
    }
    while(1)
    {
        int m,day;
        cin>>m>>day;if(!m)return 0;
        const char* str[10]={0,"Monday", "Tuesday", "Wednesday","Thursday", "Friday", "Saturday", "Sunday"};
        cout<<str[d[m][day]]<<endl;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;


int main()
{
    int m[50],d[50];
    int x = 0;
    string Day[7] = {"Thursday", "Friday","Saturday","Sunday","Monday", "Tuesday", "Wednesday"};
    int BanyakHari[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
    string ThatDayIs[50];

    do
    {
        int DayinBetween = 0;
        cin >> m[x] >> d[x];
        if((m[x] == 0) && (d[x] == 0))
        {
            break;
        }
        //Check banyak hari antara 1 Januari - Input
        for(int y = 0; y < m[x]-1; y++)
        {
            DayinBetween = DayinBetween + BanyakHari[y];
        }
        DayinBetween = (DayinBetween + d[x] - 1)%7;


        ThatDayIs[x] = Day[DayinBetween];

        x++;
    }
    while(x < 50);

    for(int z = 0; z < x; z++)
    {
        cout << ThatDayIs[z] << endl;
    }


}

C++: from datetime import date
import calendar

while True:
    m, d = map(int, input().split())
    if not m:
        break
    print(calendar.day_name[date(2004, m, d).weekday()])

C++: #include<stdio.h>
int main(){
	int M,D,Y;
	
	for(;;){
		scanf("%d%d", &M, &D);
		if(M==0 && D==0)break;
		for(;M>1;M--){
			D+=31;
			if(M==12 || M==10 || M==7 || M==5){
				D-=1;
			}
			if(M==3){
				D-=2;
			}
		}
		D%=7;
		switch(D){
			case 0:
				puts("Wednesday");
				break;
			case 1:
				puts("Thursday");
				break;
			case 2:
				puts("Friday");
				break;
			case 3:
				puts("Saturday");
				break;
			case 4:
				puts("Sunday");
				break;
			case 5:
				puts("Monday");
				break;
			case 6:
				puts("Tuesday");
				break;
		}
			
	}
	return 0;
}

C++: #include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

void print(int i){
	if(i==0)cout<<"Monday"<<endl;
	if(i==1)cout<<"Tuesday"<<endl;
	if(i==2)cout<<"Wednesday"<<endl;
	if(i==3)cout<<"Thursday"<<endl;
	if(i==4)cout<<"Friday"<<endl;
	if(i==5)cout<<"Saturday"<<endl;
	if(i==6)cout<<"Sunday"<<endl;
	return;
}

int main(){
	int m,d,num=3;
	int season[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	while(cin>>m>>d,m){
		num=3;
		rep(i,m-1)num+=season[i];
		num+=d-1;
		num%=7;
		print(num);
	}
	return 0;
}

C++: #include<stdio.h>

int main(void)
{
	int a=0,b=0,day=0;

	while(day != 10)
	{
		scnaf("%d %d",&a,&b);
		if(a==0 || b ==0)break;
		else if(a==1 || a==4 || a==7)
			day = 3 + b % 7;
		else if(a==2 || a==8)
			day = 6 + b % 7;
		else if(a==3 || a==11)
			day = b % 7;
		else if(a==5)
			day = 5 + b % 7;
		else if(a == 6)
			day = 1 + b % 7;
		else if(a==9 || a==12)
			day = 2 + b % 7;
		else 
			day = 4 + b % 7;
		if(day > 6)
			day-=7;
		switch (day)
		{
		case 1:
			printf("Monday\n");
			break;
		case 2:
			printf("Tuesday\n");
			break;
		case 3:
			printf("Wednesday\n");
			break;
		case 4:
			printf("Thursday\n");
			break;
		case 5:
			printf("Friday\n");
			break;
		case 6:
			printf("Saturday\n");
			break;
		case 0:
			printf("Sunday\n");
			break;
		}
	}
  return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int main() {
	int days[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	string week[] = {"Wednexday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};
	for(int month, day; cin >> month >> day && month && day;) {
		int sum = 0;
		rep(i,month - 1) {
			sum += days[i];
		}
		sum += day;
		sum %= 7;
		cout << week[sum] << endl;
	}
	return 0;
}

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

int main(){
	string week[7] = {"Mondey","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
	int m,d,cnt,mc;

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

		mc = 1;
		cnt = 3;
		while(1){
			for(int i=1 ; i <= month[mc-1] ; i++, cnt++){
				if(m==mc && d==i) break;
			}
			if(m==mc) break;
			mc++;
		}
		cout << week[cnt%7] << endl;
	}
	return 0;
}