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 <iostream>
using namespace std;
int days(int m){
	if(m==1)
		return 0;
	else if(m==2)
		return days(1)+31;
	else if(m==3)
		return 29+days(2);
	else if(m==4)
		return 31+days(3);
	else if(m==5)
		return 30+days(4);
	else if(m==6)
		return 31+days(5);
	else if(m==7)
		return 30+days(6);
	else if(m==8)
		return 31+days(7);
	else if(m==9)
		return 31+days(8);
	else if(m==10)
		return 30+days(9);
	else if(m==11)
		return 31+days(10);
	else if(m==12)
	    return 30+days(11);
}
int main(){
	int m, d;
	while(cin>>m>>d){
		if(m==0)
			break;
		d+=days(m);
		if(d%7==1)
			cout<<"Thursday";
		else if(d%7==2)
			cout<<"Friday";
		else if(d%7==3)
			cout<<"Saturday";
		else if(d%7==4)
			cout<<"Sunday";
		else if(d%7==5)
			cout<<"Monday";
		else if(d%7==6)
			cout<<"Tuesday";
		else
			cout<<"Wednesday";
		cout<<endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(void){

  int month[13] ={0,31,29,31,30,31,30,31,31,30,31,30,31};
  int m,d;

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

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

    sum += d; 
    sum %= 7;

    switch(sum){
    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;
    }
  }
  return 0;
}

C++: #include<iostream>
 
int main()
{
	const int dayMaxSum[13] = 
	{
		0,
		31,
		60,
		91,
		121,
		152,
		182,
		213,
		244,
		274,
		305,
		335,
		366
	};

	int month=1,day=0,daySum=0;//month=0で終了するため1で初期化

	while(std::cin >> month >> day && month!=0)
	{
		daySum = dayMaxSum[month-1]+day;

		switch(daySum%7)
		{
		case 1:
			std::cout << "Thursday";
			break;
		case 2:
			std::cout << "Friday";
			break;
		case 3:
			std::cout << "Saturday";
			break;
		case 4:
			std::cout << "Sunday";
			break;
		case 5:
			std::cout << "Monday";
			break;
		case 6:
			std::cout << "Tuesday";
			break;
		case 0:
			std::cout << "Wednesday";
			break;
		}
		std::cout << '\n';

		daySum=0;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;

int main() {
	int m, d;
	string week[] = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
			"Saturday", "Sunday" };
	int day[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	while (cin >> m >> d) {
		if (m == 0)break;
		bool flag=false;
		int mc = 1;
		int cnt = 3;
		while (1) {
			for (int i = 1; i <= day[mc - 1]; ++i, cnt++) {
				if (mc == m && d == i) {
					cout << week[cnt % 7] << endl;
					flag=true;
					break;
				}
			}
			if(flag)break;
			mc++;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
#include <ctype.h>

using namespace std;

int main() {
    int M[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
    string W[7]={"Monday",
        "Tuesday",
        "Wednesday",
        "Thursday",
        "Friday",
        "Saturday",
        "Sunday"};
    
    int x,y;
    while(scanf("%d%d",&x,&y)!=EOF){
        if(x==0||y==0){
            break;
        }
        int day=0;
        for(int i=1; i<x; i++){
            day+=M[i];
        }
        day+=y+2;
        int week = day % 7;
        cout<<W[week]<<endl;
    
    }
    return 0;
}

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

int main() {
	int mth[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	char wks[][16]={"Wedneday","Thursday","Friday","Saturday","Sunday",
				"Monday","Tuesday"};
	int m,d;
	while(cin>>m>>d,m){
		int days=0;
		for(int i=1;i<m;i++) days+=mth[i];
		days+=d; cout<<wks[days%7]<<endl;
	}
}

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

string days[7] =
{
	"Wednesday",
	"Thursday",
	"Friday",
	"Saturday",
	"Sunday",
	"Monday",
	"Tuesday"
};

int daysPerMonth[11] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30 };

int main()
{
	int m, d;
	while (cin >> m >> d)
	{
		int day = 0;
		for (int i = 0; i < m - 1; i++)
		{
			day += daysPerMonth[i];
		}
		day += d;

		cout << days[day % 7] << endl;
	}

	return 0;
}

C++: #define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
	int m, d;
	for (; cin >> m >> d;)
	{
		if (m == 0 && d == 0)
		{
			break;
		}

		vector<int> mon = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

		int mm = 0;
		for (int i = 0; i < m; i++)
		{
			mm += mon.at(i);
		}
		int y = (3 + mm + d) % 7;

		vector<string> sy = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

		cout << sy.at(y) << endl;
	}
}

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

int main(void){

    vector<string> day(7);
    day[0] = "Saturday";
    day[1] = "Sunday";
    day[2] = "Monday";
    day[3] = "Tuesday";
    day[4] = "Wednesday";
    day[5] = "Thursday";
    day[6] = "Friday";
    int x,y;

    while(1){
        cin >> x >> y;
        int h = 20;
        int n = 4;
        if(x == 0){
            break;
        }
        if(x == 1 || x == 2){
            n--;
            x+=12;
        }
                       
        int w = n + n/4 + h/4 - 2*h + 13*(x+1)/5 + y;
        //cout << w << endl;
       
        //cout << w%7 << endl;

        string ans = day[w%7];

        cout << ans << endl;
    }
    return 0;
}

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

#define YEAR 2004

using namespace std;

int main() {
	vector<string> week;
	week.push_back("Monday");
	week.push_back("Tuesday");
	week.push_back("Wednesday");
	week.push_back("Thursday");
	week.push_back("Friday");
	week.push_back("Saturday");
	week.push_back("Sunday");
	int m,d,w;
	while(cin>>m>>d){
		if(m==0 || d==0){ break; }
		w = (YEAR + YEAR/4 - YEAR/100 + YEAR/400 + (13*m+8)/5 + d) % 7;
		cout<<week[w]<<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 && d == 0) break;

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