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 <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
	freopen("testcase.wdt", "r", stdin);
	// 2004/01/01 is Thursday
	const string week[] = {
	"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
	const int days[] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; 
	string str = "";
	
	while (1){
		int month, day;		
		cin >> month >> day;
		if (month == 0 && day == 0){
			break;
		} // end if
		int num = 0;
		int i;
		for (i = 0; i < month; ++i){
			num += days[i];
		} // end for
		num += day;
		cout << week [( num - 1 + 3 ) % 7 ] << endl;
	} // end while
		
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n,m;
  int x[12] = {0,3,4,0,2,5,0,3,6,1,4,0};
  while(cin >>n>>m,n||m){
    if((m+x[n-1])%7 == 1) cout <<"Thursday"<<endl;
    if((m+x[n-1])%7 == 2) cout <<"Friday"<<endl;
    if((m+x[n-1])%7 == 3) cout <<"Saturday"<<endl;
    if((m+x[n-1])%7 == 4) cout <<"Sunday"<<endl;
    if((m+x[n-1])%7 == 5) cout <<"Monday"<<endl;
    if((m+x[n-1])%7 == 6) cout <<"Tuesday"<<endl;
    if((m+x[n-1])%7 == 0) cout <<"Wednesday"<<endl;
  }
  return 0;
}

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

int manth[] = {31,29,31,30,31,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 += manth[i];
		}
		d += D;
		d %= 7;
		cout << date[d] << endl;
	}
}

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

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

int main(){
    int m,d;

    while(cin>>m>>d,m||d){
        for(int i=1;i<m;i++)d+=month[i];
        d=(d-1)%7+3;
        string ans;
        switch(d){
        case 0:ans="Monday";break;
        case 1:ans="Tuesday";break;
        case 2:ans="Wednesday";break;
        case 3:ans="Thursday";break;
        case 4:ans="Friday";break;
        case 5:ans="Saturday";break;
        case 6:ans="Sunday";break;
        }

        cout<<ans<<endl;
    }
}

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

int main()
{
	string week[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
	int day[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	vector<int> firstDay;
	int a, b;
	int i;

	firstDay.push_back(3);
	for (i = 0; i < 12; i++) {
		firstDay.push_back( (firstDay[i]+day[i])%7 );
	}

	while(cin>>a>>b, a||b) {
		cout<<week[ (firstDay[a-1] + b-1) % 7 ]<<endl;
	}

	return 0;
}

C++: #include<stdio.h>

void y(int x ){
	if(x == 0)
		puts("Thursday");
	else if(x == 1)
		puts("Friday");
	else if(x == 2)
		puts("Saturday");
	else if(x == 3)
		puts("Sunday");
	else if(x == 4)
		puts("Monday");
	else if(x == 5)
		puts("Tuesday");
	else if(x == 6)
		puts("Wednesday");
}

int main(void){
	int M,D;
	while(1){
		int date = 0,ans;
		int m[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
		
		scanf("%d%d", &M, &D);
		if(M == 0 && D  == 0)break;
		for(int i = 1; i <= 12 ; i++){
			for(int j = 1; j <= m[i-1]; j++){
				if(i == M && j == D){
					ans = date;
				}
	//			printf("%d%dú%d\n",i,j,date%7);
	//			y(date%7);
				date++;
			}
		}
		y(ans%7);
	}
	
	return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int hoge[] = {31,29,31,30,31,30,31,31,30,31,30,31};
  string s[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

  int foo[12][31];
  int dd = 3;
  for (int i=0; i<12; i++) {
    for (int j=0; j<hoge[i]; j++) {
      foo[i][j] = dd%7;
      dd++;
    }
  }
  
  int m, d;
  while(cin >> m >> d, m+d) {
    cout << s[foo[m-1][d-1]] << endl;
  }
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	string week[7] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
	int m,d,count_w, count_m;
	while(cin >> m >> d){
		if(m == 0) return 0;
		count_m = 1;
		count_w = 3;
		while(m != count_m){
			for(int i=1; i<=month[count_m-1]; i++, count_w++){
				if(m==count_m && d==i) break;
			}
			count_m++;
		}
		cout << week[count_w%7] << endl;
	}
}

C++: import java.util.*;
public class Main {
	static String[] Day=new String[10];
	public static void setDay(){
		Day[0]="Wednesday";
		Day[1]="Thursday";
		Day[2]="Friday";
		Day[3]="Saturday";
		Day[4]="Sunday";
		Day[5]="Monday";
		Day[6]="Tuesday";
	}
	static int[] Month=new int[20];
	public static void setMonth(){
		Month[1]=31;
		Month[2]=29;
		Month[3]=31;
		Month[4]=30;
		Month[5]=31;
		Month[6]=30;
		Month[7]=31;
		Month[8]=31;
		Month[9]=10;
		Month[10]=31;
		Month[11]=30;
		Month[12]=31;
	}
	public static void main(String args[]){
		setDay();
		setMonth();
		Scanner in=new Scanner(System.in);
		int date,month,days;
		while(in.hasNextInt()){
			month=in.nextInt();
			date=in.nextInt();
			if(month==0&&date==0)
				break;
			days=0;
			for(int i=1;i<month;i++)
				days+=Month[i];
			days+=date;
			System.out.println(Day[days%7]);
		}
		in.close();
	}
}

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

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

C++: #include<iostream>

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

int main(){

	int month, date;

	while (std::cin >> month >> date, month || date){
		int day = 2;

		for (int i = 1; i < month; i++){
			int numdate = 31;
			if (i == 4 || i == 6 || i == 9 || i == 11)numdate = 30;
			else if (i == 2)numdate = 29;

			day = (day + numdate) % 7;
		}

		day = (day + date) % 7;

		std::cout << ans[day] << std::endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int main(){
	int a,b,month[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	string week[]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
	while(cin>>a>>b){
		if(a==0 && b==0)break;
		for(int i=1;i<a;i++){
			b+=month[i];
		}
		cout<<week[b%7]<<endl;
	}
	return 0;
}