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 main()
{
	int date[13][32];
	for(int i = 1;i<=31;i++)date[1][i] = i;
	for(int i = 1;i<=28;i++)date[2][i] = i+3;
	for(int i = 1;i<=31;i++)date[3][i] = i+4;
	for(int i = 1;i<=31;i++)date[4][i] = i;
	for(int i = 1;i<=31;i++)date[5][i] = i+2;
	for(int i = 1;i<=31;i++)date[6][i] = i+5;
	for(int i = 1;i<=31;i++)date[7][i] = i;
	for(int i = 1;i<=31;i++)date[8][i] = i+3;
	for(int i = 1;i<=31;i++)date[9][i] = i+6;
	for(int i = 1;i<=31;i++)date[10][i] = i+1;
	for(int i = 1;i<=31;i++)date[11][i] = i+4;
	for(int i = 1;i<=31;i++)date[12][i] = i+6;
	
	int month,day;
	while(true)
	{
		cin >> month;
		cin >> day;
		if(month==0&&day==0)break;
		switch (date[month][day] % 7)
		{
			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<stdio.h>

int main()
{
	int x,y,d;
	while(scanf("%d %d",&x,&y))
	{
		if(x==0)
		{
			return 0;
		}
		else if(x==1||x==2)
		{
			d=(2003+2003/4-2003/100+2003/400+(13*(x+12)+8)/5+y)%7;
		}
		else if(x>=13)
		{
			d=7;
		}
		else
		{
			d=(2004+2004/4-2004/100+2004/400+(13*x+8)/5+y)%7;
		}

		if(d==0)
		{
			printf("Sunday\n");
		}
		else if(d==1)
		{
			printf("Monday\n");
		}
		else if(d==2)
		{
			printf("Tuesday\n");
		}
		else if(d==3)
		{
			printf("Wednesday\n");
		}
		else if(d==4)
		{
			printf("Thursday\n");
		}
		else if(d==5)
		{
			printf("Friday\n");
		}
		else if(d==6)
		{
			printf("Saturday\n");
		}
		else if(d==7)
		{
		}
	}
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <queue>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <cctype>
#include <cstdlib>
using namespace std;

#define INF (1 << 20)
#define EPS (1e-10)
#define EQ(a,b) (fabs((a)-(b)) < EPS)

int main(){
	int dn[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	string youbi[7] = {"Monday", "Tuesday", "Wednesday", "Thursday",
		"Friday", "Saturday", "Sunday"};
	int m, d;
	while (cin >> m >> d) {
		if (m == 0) break;
		int sum = 0;
		for (int i = 1; i < m; ++i) {
			sum += dn[i];
		}
		sum += d;
		cout << youbi[sum % 7 + 2] << endl;
	}
	return 0;
}

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

int main() {
	string str[50];
	int f;
	for (int i = 0;; i++) {
		int a, b;
		cin >> a >> b;
		if (a == 0 && b == 0) {			
			f = i;
			break;
		}
		{
			if (a == 2) {
				b += 3;
			}
			if (a == 3) {
				b += 4;
			}
			if (a == 4) {
				b += 0;
			}
			if (a == 5) {
				b += 2;
			}
			if (a == 6) {
				b += 5;
			}
			if (a == 7) {
				b += 0;
			}
			if (a == 8) {
				b += 3;
			}
			if (a == 9) {
				b += 6;
			}
			if (a == 10) {
				b += 1;
			}
			if (a == 11) {
				b += 4;
			}
			if (a == 12) {
				b += 6;
			}
		}
		//?????\????±????(52???73)
		{
			if ((b & 7) == 0) {
				str[i] = "Wednesday";
			}
			if ((b & 7) == 1) {
				str[i] = "Thursday";
			}
			if ((b & 7) == 2) {
				str[i] = "Friday";
			}
			if ((b & 7) == 3) {
				str[i] = "Saturday";
			}
			if ((b & 7) == 4) {
				str[i] = "Sunday";
			}
			if ((b & 7) == 5) {
				str[i] = "Monday";
			}
			if ((b & 7) == 6) {
				str[i] = "Tuesday";
			}
		}
	}

	for (int i = 0; i < f; i++){
		if (str[i]=="Wednesday") {
			cout << "Wedne";
			cout << "sday" << endl;
		}else cout << str[i] << endl;
	}

	char c;
	cin >> c;

	return 0;
}

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

int main()
{
	int day[366];
	int month[12] = {0,31,60,91,121,152,182,213,244,274,305,335};
	int m,d;
	
	for(int i=0;i<366;++i)
		day[i] = i%7;
	
	while(cin >> m >> d){
		if(!m)
			break;

		switch(day[month[m-1] + d-1]){
		case 0:cout <<"Thursday"		<<endl;break;
		case 1:cout <<"Friday"			<<endl;break;
		case 2:cout <<"Saturday"		<<endl;break;
		case 3:cout <<"Sunday"			<<endl;break;
		case 4:cout <<"Monday"			<<endl;break;
		case 5:cout <<"Tuesday"			<<endl;break;
		case 6:cout <<"Wednesday"	<<endl;break;
		}

	}
	return 0;
}

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

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

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

int main()
{
	int day[365];
	int month[12] = {0,31,60,91,121,152,182,212,243,273,304,334};
	int m,d;
	
	for(int i=0;i<365;++i)
		day[i] = i%7;
	
	while(cin >> m >> d){
		if(!m & !d)
			break;

		switch(day[month[m-1] + d]){
		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;
}