Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

//Sliceconvtoi ...
func Sliceconvtoi() []int {
	strs := strings.Split(sc.Text(), " ")

	var ints []int
	var x int

	for _, s := range strs {
		x, _ = strconv.Atoi(s)
		ints = append(ints, x)
	}

	return ints
}

func main() {
	for sc.Scan() {
		i := Sliceconvtoi()

		if i[0] == 0 && i[1] == 0 {
			break
		}

		m := time.Month(i[0])
		d := i[1]
		t := time.Date(2004, m, d, 0, 0, 0, 0, time.Local)
		fmt.Println(t.Weekday())
	}

}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;


int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
char date[7][10] = {"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};


int main(){
    int M,D,days=0;
    
    while(1){
        days=0;
        scanf("%d%d",&M,&D);
        if(M+D==0) break;
        
        for(int i=0;i<M-1;i++)
            days+=month[i];
    
        printf("%s\n",date[(days+D)%7]);
    }
    
    return 0;
}

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

int main() {
	string youbi[7] = {"Thursday","Friday","Suturday","Sunday","Monday","Tuesday","Wednesday"};
	int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
	
	int gathu,nichi;
	while ( cin >> gathu >> nichi,gathu ) {
		int keika = 0;
		for ( int i = 0; i < gathu - 1; i++ ) {
			keika += month[i];
		}
		keika += nichi;
		
		cout <<  youbi[keika % 7 - 1] << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {

	int m, d;
	int day[12]={31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	char week[][16]={"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};

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

		for(int i=0; i<m-1; i++) {
			d+=day[i];
		}
 
		cout << week[d%7] << endl;

	}

	return 0;

}

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

int main()
{
  int m,d;

  string week[7] = {"Thursday", "Friday", "Saturday", "Sunday","Mondy", "Tuesday", "Wednesday"};
  int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

  while ( scanf("%d %d", &m, &d), m != 0 ) {
    int day = 0;
    for (int i = 0; i < (m - 1); i++) {
      day += month[i];
    }
    day += d;
 
    cout << week[(day%7)-1] << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

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

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

int main()
{
	int month, day, date;

	while ( true )
	{
		date = 2;

		cin >> month >> day;

		if ( month == 0 )
		{
			break;
		}

		for ( int i = 0; i < month - 1; i++ )
		{
			date += dateOfMonth[i];
		}

		date += day;

		cout << dates[ date % 7 ] << endl;
	}

	return 0;
}

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

using namespace std;

int main(){
	string y[7] = {"Wednesday", "Thrsday", "Frinday", "Saturday", "Sunday", "Monday", "Tuesday"};
	int mon[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

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

		while(m != 0){
			d = d + mon[m-1];
			m--;
		}
		cout << y[d%7] << endl;
	}
}

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

int Zellers_congruence(int y, int m, int d) {
	int num;
	if (m < 3)num = (y - 1) + (y - 1) / 4 - (y - 1) / 100 + (y - 1) / 400 + (13 * (m + 12) + 8) / 5 + d;
	else num = y + y / 4 + -y / 100 + y / 400 + (13 * m + 8) / 5 + d;
	return num % 7;
}

int main() {
	int year=2004, month, day;
	while (cin>>month>>day&&month!=0&&day!=0) {
		switch (Zellers_congruence(year, month, day)) {
		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; break; }
		default:cout << "error" << endl;
		}
	}
}

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

using namespace std;

int main()
{ 
	const string day[7] = { "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday" };
	const int days[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

	int month, date;

	while (cin >> month >> date, month)
	{
		int sum = 0;
		for (int i = 1; i < month; ++i)
			sum += days[i - 1];

		sum += date;
		cout << day[(sum % 7) - 1] << endl;
	}

	return 0;
}

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

int main()
{
	std::vector<std::string> day_of_week{
		"Thursday",
		"Friday",
		"Suterday",
		"Sunday",
		"Monday",
		"Tuesday",
		"Wednesday"
	};

	std::vector<int> day_num_of_month{
		31,
		29,
		31,
		30,
		31,
		30,
		31,
		31,
		30,
		31,
		30,
		31
	};

	int month = 0;
	int day = 0;

	while (std::cin >> month >> day)
	{
		if (0 == month) { break; }

		int days_elapsed = 0;
		for (int m = 1; m < month; ++m)
		{
			days_elapsed += day_num_of_month[m - 1];
		}
		days_elapsed += day;

		std::cout << day_of_week[(days_elapsed - 1) % 7] << std::endl;
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
	int M, D, days;
	int daysOfMonth[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	string daysOfWeek[] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};
	while (1) {
		cin >> M >> D;
		if (M == 0 && D == 0)
			break;
		days = 0;
		for (int i = 0; i < M; i++)
			days += daysOfMonth[i];
		days += D;
		cout << daysOfWeek[days % 7] << 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;
}

C++: #include<iostream>

int day_of_month( int m )
{
	switch( m ){
	 	case 2:
			return 29;
			break;
		case 4:
		case 6:
		case 9:
		case 11:
			return 30;
			break;
		default:
			return 31;
			break;
	}
}

int main()
{
	int m,d;
	const char week[][20] = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
	
	while( 1 ){
		std::cin >> m >> d;
		if( !m && !d ) break;
		
		int nm = 1, nd = 1, nw = 3;
		while( 1 ){
			if( nm == m && nd == d ) break;
			nd++;
			nw = ( nw + 1 ) % 7;
			
			if( nd > day_of_month( nm ) ){
			 	nd = 1;
				nm++;
			}
		}
		
		std::cout << week[nw] << std::endl;
	}

 	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
 
int month[] = {31,29,31,30,31,30,31,31,30,31,30,31};
string date[] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
 
int main(){
    int M, D;
    while( cin >> M >> D, M ){
        int d = 3;
        for(int i=0; i<M-1; i++ ){
            d += month[i];
        }
        d += D;
        d %= 7;
        cout << date[d] << endl;
    }
}