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++: //#define _USE_MATH_DEFINES
//#include <cmath>
#include <iostream>
//#include <stdio.h>
//#include <stdlib.h>
//#include <iomanip>
//#include <vector>
#include <string>
//#include <algorithm>
//#include <functional>
#include <time.h>
//#include <sstream>
//#include <queue>

using namespace std;


int main(){

	int m, d;
	int days[13] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	int sum = 0;
	string wd[7] = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };


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

		for (int i = 1; i < m; i++){
			sum += days[i];
		}
		sum += d;

		cout << wd[(sum+2) % 7] << endl;

	}


	return 0;
}

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
using namespace std;

int main() {
	int m, d;
	while (cin >> m >> d&&m != 0 && d != 0) {
		int sum = 0;
		for (int i = 1; i < m; i++) {
			if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) {
				sum += 31;
			}
			else if (i == 2) {
				sum += 29;
			}
			else {
				sum += 30;
			}
		}
		sum += d;
		if (sum % 7 == 1) {
			cout << "Thursday" << endl;
		}
		else if (sum % 7 == 2) {
			cout << "Friday" << endl;
		}
		else if (sum % 7 == 3) {
			cout << "Saturday" << endl;
		}
		else if (sum % 7 == 4) {
			cout << "Sunday" << endl;
		}
		else if (sum % 7 == 5) {
			cout << "Monday" << endl;
		}
		else if (sum % 7 == 6) {
			cout << "Tuesday" << endl;
		}
		else {
			cout << "Wednesday" << endl;
		}
	}
}

C++: #include <iostream>
#include <string>
using namespace std;
int main() {
  int m[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  string w[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
    "Saturday", "Sunday"};
  int x, y;
  while (cin >> x >> y) {
    if (x == 0) break;
    int d = 2;
    while (--x)
      d += m[x];
    d += y;
    cout << w[d % 7] << endl;
  }
}

C++: #include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
using namespace std;

int main(){
	int m,n,end[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	while(1){
		int day=0,r;
		cin>>m>>n;
		if(m==0) break;
		rep(i,0,m-1) day+=end[i];
		day+=n;
		r=day%7;
		if(r==1) cout<<"Thursday"<<endl;
		else if(r==2) cout<<"Friday"<<endl;
		else if(r==3) cout<<"Saturday"<<endl;
		else if(r==4) cout<<"Sunday"<<endl;
		else if(r==5) cout<<"Monday"<<endl;
		else if(r==6) cout<<"Tuesday"<<endl;
		else if(r==0) cout<<"Wednesday"<<endl;
	}
}

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

int main() {
  int month, date;
  int day[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  const char *label[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
  int day_sum[12];
  int x;

  day_sum[0] = 0;
  for (int i=1; i<12; i++) {
    day_sum[i] = day_sum[i-1] + day[i-1];
  }

  while (1) {
    cin >> month >> date;
    if (!month && !date) break;
    x = day_sum[month-1] + date + 2;
    cout << label[x%7] << endl;
  }

  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int m,d,n=0,date[50]={0},i=0;
	while(cin>>m&&m!=0){
		cin>>d;
		switch(m){
			case 1:
				break;
			case 2:
				d=d+3;
				break;
			case 3:
				d=d+4;
				break;
			case 4:
				break;
			case 5:
				d=d+3;
				break;
			case 6:
				d=d+5;
				break;
			case 7:
				break;
			case 8:
				d=d+3;
				break;
			case 9:
				d=d+6;
				break;
			case 10:
				d=d+1;
				break;
			case 11:
				d=d+4;
				break;
			case 12:
				d=d+6;
				break;
		}
		date[i]=d%7;
		i++;
		n++;
	}
	for(int i=0;i<n;i++){
		switch(date[i]){
			case 0:
				cout<<"Wednesday"<<endl;
				break;
			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;
		}
	}
}

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

const char *weeks[]={"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
const int days[]={0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(true){
        int month, day;
        cin>>month>>day;
        if(month==0) break;
        int week=3;
        for(int i=1; i<month; i++) week=(week+days[i])%7;
        week=(week+day)%7;
        cout<<weeks[week]<<'\n';
    }
    return 0;
}

C++: #include <iostream>
#include <string>

using namespace std;

//0027
int main(){
	int days[] = {31,29,31,30,31,30,31,31,30,31,30,31};
	string week[7] = {"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
	int m, d;
	while(cin >> m >> d, m||d){
		int ans = 0;
		for(int i=1; i<m; ++i){
			ans += days[i-1];
		}
		ans += d;

		ans = ans % 7;
		cout << week[ans] <<endl;

	}
}

C++: #include<iostream>
#include<string>
#include<memory.h>
using namespace std;
int main()
{
	//2004-1-1 Tuesday
	int a[370];
	string youbi[7] = {
		 "Monday", "Tuesday","Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
	int m[13] = { 0,0, 31,60 ,91,121, 152, 182,213 , 244, 274, 305, 335 };
	for (int i = 3; i <= 365+3; i++){
		a[i] = i % 7;
	}
	while (true){
		int x, y;
		cin >> x >> y;
		if (x == 0 && y == 0)break;
		cout << youbi[a[m[x] + y + 2]] << endl;
	}
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

int dayofweek(int year, int month, int day)
{
	struct tm  t;

	t.tm_year = year - 1900;    /* ??´????????´ */
	t.tm_mon = month - 1;        /* ???????????´ */
	t.tm_mday = day;            /* ??\ */
	t.tm_hour = 0;                /* ??? */
	t.tm_min = 0;                /* ??? */
	t.tm_sec = 0;                /* ?§? */
	t.tm_isdst = -1;            /* ????????? */

	if (mktime(&t) == -1)        /* ???????????±??? */
		return (-1);
	return (t.tm_wday);
}

int main() {
	map<int, string>m;
	m[0] = "Sunday";
	m[1] = "Monday";
	m[2] = "Tuesday";
	m[3] = "Wednesday";
	m[4] = "Thursday";
	m[5] = "Friday";
	m[6] = "Saturday";
	while (1) {
		int a, b; cin >> a >> b;
		if (!a)break;
		int num = dayofweek(2004, a, b);
		cout << m[num] << endl;
	}
	return 0;
}