Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func zeller(month, day int) 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
}

func main() {
	scanner.Split(bufio.ScanWords)
	for {
		month := nextInt()
		day := nextInt()
		if month == 0 && day == 0{
			break
		}
		switch zeller(month, day) {
		case 0:
			fmt.Println("Sunday")
		case 1:
			fmt.Println("Monday")
		case 2:
			fmt.Println("Tuesday")
		case 3:
			fmt.Println("Wednesday")
		case 4:
			fmt.Println("Thursday")
		case 5:
			fmt.Println("Friday")
		case 6:
			fmt.Println("Saturday")
		}
	}
}

C++: int zeller(int y , int m , int d){
	if(m==1 || m==2) m+=12; y-=1;
	return(y + y/4 - y/100 + y/400 + ((13*m+8)/5) + d )%7;
}

int main(){
	int m , d , w=4 , fw;
	while (cin >> m >> d, m){
		switch(zeller(2004,m,d)){
			case 0:
			cout << "Sunday" << endl;
			break;
			case 1:
			cout << "Monday" << endl;
			break;
			case 2:
			cout << "Tuesday" << endl;
			break;
			case 3:
			cout << "Wednesday" << endl;
			break;
			case 4:
			cout << "Thursday" << endl;
			break;
			case 5:
			cout << "Friday" << endl;
			break;
			case 6:
			cout << "Saturday" << endl;
		}
	}
	return 0; 
}

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;
}