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++: #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;
}