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;

int main(){
	char *dotw[7] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	int mod[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	int i, day, mon, dcnt;
	while(true){
		dcnt = 0;
		cin>>mon>>day;
		if(mon==0)
			break;
		for(i=1;i<mon;i++){
			dcnt += mod[i-1];
		}
		dcnt += day + 2;
		cout << dotw[dcnt%7] << endl;
	}
	return 0;
}

C++: #include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <map>
#define INF 100000000
#define rep(i,a) for(int i=0;i<(a);i++)

using namespace std;
typedef long long ll;

int main(){
    int hosei[]={0,4,0,1,4,6,2,4,0,3,5,1,3};
    string day[]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
    int m,n;
    while(1){
        cin>>m>>n;
        if(!(m||n))break;
        cout<<day[(hosei[m]+n%7-1)%7]<<endl;
    }
    
    
    return 0;
}

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

int Zeller(int month,int day){
	int year = 2004;
	if(month == 1 || month==2){
		year--;
		month += 12;
	}
	return (year + year/4 - year/100 + year/400 + (13*month+8)/5 + day)%7;
}

int main(){

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

		switch(Zeller(month,day)){
		case 0:
			printf("Sunday\n");
			break;
		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;
		}

	}

    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	int m, d;
	std::vector<int> num_date_month;

	num_date_month.push_back(0);
	num_date_month.push_back(31); //31
	num_date_month.push_back(60); //29
	num_date_month.push_back(91); //31
	num_date_month.push_back(121); //30
	num_date_month.push_back(152); //31
	num_date_month.push_back(182); //30
	num_date_month.push_back(213); //31
	num_date_month.push_back(244); //31
	num_date_month.push_back(274); //30
	num_date_month.push_back(305); //31
	num_date_month.push_back(335); //30

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	while(ifs >> m >> d){
#else
	while(std::cin >> m >> d){
#endif
		if(m == 0 && d == 0){
			break;
		}
		int num_date = num_date_month[m - 1] + d - 1;
		int day = num_date % 7;

		switch(day){
		case 0:
			std::cout << "Thursday" << std::endl;
			break;
		case 1:
			std::cout << "Friday" << std::endl;
			break;
		case 2:
			std::cout << "Saturday" << std::endl;
			break;
		case 3:
			std::cout << "Sunday" << std::endl;
			break;
		case 4:
			std::cout << "Monday" << std::endl;
			break;
		case 5:
			std::cout << "Tuesday" << std::endl;
			break;
		case 6:
			std::cout << "Wednesday" << std::endl;
			break;
		default:
			break;
		}

	}

	
	return 0;
}

C++: // includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
int offset[12] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};
string date[7] = {"Monday", "Tuesday", "Wednesay", "Thursday", "Friday", "Saturday", "Sunday"};

int main(int argc, char const* argv[])
{
  int m, d;
  while(cin >> m >> d){
    if(m == 0 && d == 0)break;
    int days = offset[m - 1] + d;
    days = (2 + days) % 7;
    cout << date[days] << endl;
  }
	return 0;
}

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

int main(){
int a,b,day;
string Day;
int days[]={31,29,31,30,31,30,31,31,30,31,30,31};
string Days[]={Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday}

while(cin>>a>>b){
day=4;
for(int i=0;i<11;i++){
if(a>i+1)b+=days[i];}
day+=b;
day%=7;
for(int i=0;i<7;i++){
if(day==i)Day=Days[i]}
cout<<Day<<endl;}}

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

int main(){
    int Month[12] = {0,31,29,31,30,31,30,31,31,30,31,30};
    int mon, day;
    while(cin>>mon>>day){
        if(!mon) break;
        int day_year = day;
        for(int i=0; i<mon; i++){
            day_year += Month[i];
        }
        switch(day_year%7){
            case 0: cout<<"Wednesday"; break;
            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;
        }
        cout<<endl;
    }
    return 0;
}

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

int main(){
	int month, day,daynum,k;
	int num[13] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	string youbi[7] = { "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday" };

	while (1){
		daynum = 0;
		cin >> month >> day;
		if (month == 0) break;
		for (int i = 1; i < month; i++){
			daynum += num[i];
		}
		daynum = daynum + day - 1;
		k = daynum % 7;
		cout << youbi[k] << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;

#define EPS 1e-8

int days[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
vector<string> yobi ={"Monday", "Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};

int main(){
	
	int m, d;
	while(cin >> m >> d, m, d){
		ll cnt = 3;
		rep(i, m-1) cnt += days[i];
		cnt += (d-1);
		cout << yobi[cnt%7] << endl;
	}
	


	
	return 0;
}