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>
using namespace std;

int main(){
	int n,m;
	string a="Monday",s="Tuesday",d="Wednesday",f="Thursday",g="Friday",h="Saturday",j="Sunday";
	while(cin>>n>>m,n||m){
		if(n==4||n==6||n==9||n==11){
			if(n==4){
				if(m==1||m==8||m==15||m==22||m==29)cout<<f<<endl;
				else if(m==2||m==9||m==16||m==23||m==30)cout<<g<<endl;
				else if(m==3||m==10||m==17||m==24)cout<<h<<endl;
				else if(m==4||m==11||m==18||m==25)cout<<"Sunday"<<endl;
				else if(m==5||m==12||m==19||m==26)cout<<"Monday"<<endl;
				else if(m==6||m==13||m==20||m==27)cout<<"Tuesday"<<endl;
				else if(m==7||m==14||m==21||m==28)cout<<"Wednesday"<<endl;
			}
			else if(n==6){
				if(m==1||m==8||m==15||m==22||m==29)cout<<s<<endl;
				else if(m==2||m==9||m==16||m==23||m==30)cout<<d<<endl;
				else if(m==3||m==10||m==17||m==24||m==31)cout<<f<<endl;
				else if(m==4||m==11||m==18||m==25)cout<<g<<endl;
				else if(m==5||m==12||m==19||m==26)cout<<h<<endl;
				else if(m==6||m==13||m==20||m==27)cout<<j<<endl;
				else if(m==7||m==14||m==21||m==28)cout<<a<<endl;
			}
			else if(n==9){
				if(m==1||m==8||m==15||m==22||m==29)cout<<d<<endl;
				else if(m==2||m==9||m==16||m==23||m==30)cout<<f<<endl;
				else if(m==3||m==10||m==17||m==24||m==31)cout<<g<<endl;
				else if(m==4||m==11||m==18||m==25)cout<<h<<endl;
				else if(m==5||m==12||m==19||m==26)cout<<j<<endl;
				else if(m==6||m==13||m==20||m==27)cout<<a<<endl;
				else if(m==7||m==14||m==21||m==28)cout<<s<<endl;
			}
			else{
				if(m==1||m==8||m==15||m==22||m==29)cout<<a<<endl;
				else if(m==2||m==9||m==16||m==23||m==30)cout<<s<<endl;
				else if(m==3||m==10||m==17||m==24||m==31)cout<<d<<endl;
				else if(m==4||m==11||m==18||m==25)cout<<f<<endl;
				else if(m==5||m==12||m==19||m==26)cout<<g<<endl;
				else if(m==6||m==13||m==20||m==27)cout<<h<<endl;
				else if(m==7||m==14||m==21||m==28)cout<<j<<endl;
			}
		}
		else if(n==1||n==3||n==5||n==7||n==8||n==10||n==12){
			if(n==1){
				if(m==1||m==8||m==15||m==22||m==29)cout<<"Thursday"<<endl;
				else if(m==2||m==9||m==16||m==23||m==30)cout<<"Friday"<<endl;
				else if(m==3||m==10||m==17||m==24||m==31)cout<<"Saturday"<<endl;
				else if(m==4||m==11||m==18||m==25)cout<<"Sunday"<<endl;
				else if(m==5||m==12||m==19||m==26)cout<<"Monday"<<endl;
				else if(m==6||m==13||m==20||m==27)cout<<"Tuesday"<<endl;
				else if(m==7||m==14||m==21||m==28)cout<<"Wednesday"<<endl;
			}
			else if(n==3){
				if(m==1||m==8||m==15||m==22||m==29)cout<<a<<endl;
				else if(m==2||m==9||m==16||m==23||m==30)cout<<s<<endl;
				else if(m==3||m==10||m==17||m==24||m==31)cout<<d<<endl;
				else if(m==4||m==11||m==18||m==25)cout<<f<<endl;
				else if(m==5||m==12||m==19||m==26)cout<<g<<endl;
				else if(m==6||m==13||m==20||m==27)cout<<h<<endl;
				else if(m==7||m==14||m==21||m==28)cout<<j<<endl;
			}
			else if(n==5){
				if(m==1||m==8||m==15||m==22||m==29)cout<<h<<endl;
				else if(m==2||m==9||m==16||m==23||m==30)cout<<j<<endl;
				else if(m==3||m==10||m==17||m==24||m==31)cout<<a<<endl;
				else if(m==4||m==11||m==18||m==25)cout<<s<<endl;
				else if(m==5||m==12||m==19||m==26)cout<<d<<endl;
				else if(m==6||m==13||m==20||m==27)cout<<f<<endl;
				else if(m==7||m==14||m==21||m==28)cout<<g<<endl;
			}
			else if(n==7){
				if(m==1||m==8||m==15||m==22||m==29)cout<<f<<endl;
				else if(m==2||m==9||m==16||m==23||m==30)cout<<g<<endl;
				else if(m==3||m==10||m==17||m==24||m==31)cout<<h<<endl;
				else if(m==4||m==11||m==18||m==25)cout<<j<<endl;
				else if(m==5||m==12||m==19||m==26)cout<<"Monday"<<endl;
				else if(m==6||m==13||m==20||m==27)cout<<"Tuesday"<<endl;
				else if(m==7||m==14||m==21||m==28)cout<<"Wednesday"<<endl;
			}
			else if(n==8){
				if(m==1||m==8||m==15||m==22||m==29)cout<<j<<endl;
				else if(m==2||m==9||m==16||m==23||m==30)cout<<a<<endl;
				else if(m==3||m==10||m==17||m==24||m==31)cout<<s<<endl;
				else if(m==4||m==11||m==18||m==25)cout<<d<<endl;
				else if(m==5||m==12||m==19||m==26)cout<<f<<endl;
				else if(m==6||m==13||m==20||m==27)cout<<g<<endl;
				else if(m==7||m==14||m==21||m==28)cout<<h<<endl;
			}
			else if(n==10){
				if(m==1||m==8||m==15||m==22||m==29)cout<<g<<endl;
				else if(m==2||m==9||m==16||m==23||m==30)cout<<h<<endl;
				else if(m==3||m==10||m==17||m==24||m==31)cout<<j<<endl;
				else if(m==4||m==11||m==18||m==25)cout<<a<<endl;
				else if(m==5||m==12||m==19||m==26)cout<<s<<endl;
				else if(m==6||m==13||m==20||m==27)cout<<d<<endl;
				else if(m==7||m==14||m==21||m==28)cout<<f<<endl;
			}
			else{
				if(m==1||m==8||m==15||m==22||m==29)cout<<d<<endl;
				else if(m==2||m==9||m==16||m==23||m==30)cout<<f<<endl;
				else if(m==3||m==10||m==17||m==24||m==31)cout<<g<<endl;
				else if(m==4||m==11||m==18||m==25)cout<<h<<endl;
				else if(m==5||m==12||m==19||m==26)cout<<j<<endl;
				else if(m==6||m==13||m==20||m==27)cout<<a<<endl;
				else if(m==7||m==14||m==21||m==28)cout<<s<<endl;
			}
		}
		else{
			if(m==1||m==8||m==15||m==22||m==29)cout<<j<<endl;
			else if(m==2||m==9||m==16||m==23)cout<<a<<endl;
			else if(m==3||m==10||m==17||m==24)cout<<s<<endl;
			else if(m==4||m==11||m==18||m==25)cout<<d<<endl;
			else if(m==5||m==12||m==19||m==26)cout<<f<<endl;
			else if(m==6||m==13||m==20||m==27)cout<<g<<endl;
			else if(m==7||m==14||m==21||m==28)cout<<h<<endl;
		}
	}
}

C++: #include<iostream>
#include<string>
using namespace std;
string d[7]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
int x[12]={31,29,31,30,31,30,31,31,30,31,30,31};
int y[12][31];
int main(){
	int a,b;
	while(true){
		cin>>a>>b;
		if(a==0){break;}
		int cnt=0;
		for(int i=0;i<12;i++){
			for(int j=0;j<x[i];j++){
				y[i][j]=cnt;
				cnt++;
			}
		}
		int D=y[a-1][b-1];
		D=(D+4)%7;
		cout<<d[D]<<endl;
	}
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>
#include <cassert>

using namespace std;


bool solve(){
	
	string str[7] = {
		"Monday",
		"Tuesday",
		"Wednesday",
		"Thursday",
		"Friday",
		"Saturday",
		"Sunday"
	};
	int hoge[]={31,29,31,30,31,30,31,31,30,31,30,31};
	int m, d;
	while(1){
		cin>> m>> d;
		if(m==0&&d==0) break;
		int num = d;
		for(int i=0;i<m-1;i++){
			num += hoge[i];
		}
		int day = (2+num)%7;
		cout<< str[day]<< endl;
		
	}
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}