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 m,d;
	while(1){
		cin>>m>>d;
		if(m==0||d==0) break;
			  if(m==1&&(d==1||d==8||d==15||d==22||d==29)){
			cout<<"Thursday"<<endl;
		}else if(m==1&&(d==2||d==9||d==16||d==23||d==30)){
			cout<<"Friday"<<endl;
		}else if(m==1&&(d==3||d==10||d==17||d==24||d==31)){
			cout<<"Saturday"<<endl;
		}else if(m==1&&(d==4||d==11||d==18||d==25)){
			cout<<"Sunday"<<endl;
		}else if(m==1&&(d==5||d==12||d==19||d==26)){
			cout<<"Monday"<<endl;
		}else if(m==1&&(d==6||d==13||d==20||d==27)){
			cout<<"Tuesday"<<endl;
		}else if(m==1&&(d==7||d==14||d==21||d==28)){
			cout<<"Wednesday"<<endl;
		}else if(m==2&&(d==1||d==8||d==15||d==22||d==29)){
			cout<<"Sunday"<<endl;
		}else if(m==2&&(d==2||d==9||d==16||d==23)){
			cout<<"Monday"<<endl;
		}else if(m==2&&(d==3||d==10||d==17||d==24)){
			cout<<"Tuesday"<<endl;
		}else if(m==2&&(d==4||d==11||d==18||d==25)){
			cout<<"Wednesday"<<endl;
		}else if(m==2&&(d==5||d==12||d==19||d==26)){
			cout<<"Thursday"<<endl;
		}else if(m==2&&(d==6||d==13||d==20||d==27)){
			cout<<"Friday"<<endl;
		}else if(m==2&&(d==7||d==14||d==21||d==28)){
			cout<<"Saturday"<<endl;
		}else if(m==3&&(d==1||d==8||d==15||d==22||d==29)){
			cout<<"Sunday"<<endl;
		}else if(m==3&&(d==2||d==9||d==16||d==23||d==30)){
			cout<<"Monday"<<endl;
		}else if(m==3&&(d==3||d==10||d==17||d==24||d==31)){
			cout<<"Tuesday"<<endl;
		}else if(m==3&&(d==4||d==11||d==18||d==25)){
			cout<<"Wednesday"<<endl;
		}else if(m==3&&(d==5||d==12||d==19||d==26)){
			cout<<"Thursday"<<endl;
		}else if(m==3&&(d==6||d==13||d==20||d==27)){
			cout<<"Friday"<<endl;
		}else if(m==3&&(d==7||d==14||d==21||d==28)){
			cout<<"Saturday"<<endl;
		}else if(m==4&&(d==1||d==8||d==15||d==22||d==29)){
			cout<<"Wednesday"<<endl;
		}else if(m==4&&(d==2||d==9||d==16||d==23||d==30)){
			cout<<"Thursday"<<endl;
		}else if(m==4&&(d==3||d==10||d==17||d==24)){
			cout<<"Friday"<<endl;
		}else if(m==4&&(d==4||d==11||d==18||d==25)){
			cout<<"Saturday"<<endl;
		}else if(m==4&&(d==5||d==12||d==19||d==26)){
			cout<<"Sunday"<<endl;
		}else if(m==4&&(d==6||d==13||d==20||d==27)){
			cout<<"Monday"<<endl;
		}else if(m==4&&(d==7||d==14||d==21||d==28)){
			cout<<"Tuesday"<<endl;
		}else if(m==5&&(d==1||d==8||d==15||d==22||d==29)){
			cout<<"Friday"<<endl;
		}else if(m==5&&(d==2||d==9||d==16||d==23||d==30)){
			cout<<"Saturday"<<endl;
		}else if(m==5&&(d==3||d==10||d==17||d==24||d==31)){
			cout<<"Sunday"<<endl;
		}else if(m==5&&(d==4||d==11||d==18||d==25)){
			cout<<"Monday"<<endl;
		}else if(m==5&&(d==5||d==12||d==19||d==26)){
			cout<<"Tuesday"<<endl;
		}else if(m==5&&(d==6||d==13||d==20||d==27)){
			cout<<"Wednesday"<<endl;
		}else if(m==5&&(d==7||d==14||d==21||d==28)){
			cout<<"Thursday"<<endl;
		}else if(m==6&&(d==1||d==8||d==15||d==22||d==29)){
			cout<<"Monday"<<endl;
		}else if(m==6&&(d==2||d==9||d==16||d==23||d==30)){
			cout<<"Tuesday"<<endl;
		}else if(m==6&&(d==3||d==10||d==17||d==24)){
			cout<<"Wednesday"<<endl;
		}else if(m==6&&(d==4||d==11||d==18||d==25)){
			cout<<"Thursday"<<endl;
		}else if(m==6&&(d==5||d==12||d==19||d==26)){
			cout<<"Friday"<<endl;
		}else if(m==6&&(d==6||d==13||d==20||d==27)){
			cout<<"Saturday"<<endl;
		}else if(m==6&&(d==7||d==14||d==21||d==28)){
			cout<<"Sunday"<<endl;
		}else if(m==7&&(d==1||d==8||d==15||d==22||d==29)){
			cout<<"Wednesday"<<endl;
		}else if(m==7&&(d==2||d==9||d==16||d==23||d==30)){
			cout<<"Thursday"<<endl;
		}else if(m==7&&(d==3||d==10||d==17||d==24||d==31)){
			cout<<"Friday"<<endl;
		}else if(m==7&&(d==4||d==11||d==18||d==25)){
			cout<<"Saturday"<<endl;
		}else if(m==7&&(d==5||d==12||d==19||d==26)){
			cout<<"Sunday"<<endl;
		}else if(m==7&&(d==6||d==13||d==20||d==27)){
			cout<<"Monday"<<endl;
		}else if(m==7&&(d==7||d==14||d==21||d==28)){
			cout<<"Tuesday"<<endl;
		}else if(m==8&&(d==1||d==8||d==15||d==22||d==29)){
			cout<<"Saturday"<<endl;
		}else if(m==8&&(d==2||d==9||d==16||d==23||d==30)){
			cout<<"Sunday"<<endl;
		}else if(m==8&&(d==3||d==10||d==17||d==24||d==31)){
			cout<<"Monday"<<endl;
		}else if(m==8&&(d==4||d==11||d==18||d==25)){
			cout<<"Tuesday"<<endl;
		}else if(m==8&&(d==5||d==12||d==19||d==26)){
			cout<<"Wednesday"<<endl;
		}else if(m==8&&(d==6||d==13||d==20||d==27)){
			cout<<"Thursday"<<endl;
		}else if(m==8&&(d==7||d==14||d==21||d==28)){
			cout<<"Friday"<<endl;
		}else if(m==9&&(d==1||d==8||d==15||d==22||d==29)){
			cout<<"Tuesday"<<endl;
		}else if(m==9&&(d==2||d==9||d==16||d==23||d==30)){
			cout<<"Wednesday"<<endl;
		}else if(m==9&&(d==3||d==10||d==17||d==24)){
			cout<<"Thursday"<<endl;
		}else if(m==9&&(d==4||d==11||d==18||d==25)){
			cout<<"Friday"<<endl;
		}else if(m==9&&(d==5||d==12||d==19||d==26)){
			cout<<"Saturday"<<endl;
		}else if(m==9&&(d==6||d==13||d==20||d==27)){
			cout<<"Sunday"<<endl;
		}else if(m==9&&(d==7||d==14||d==21||d==28)){
			cout<<"Monday"<<endl;
		}else if(m==10&&(d==1||d==8||d==15||d==22||d==29)){
			cout<<"Thursday"<<endl;
		}else if(m==10&&(d==2||d==9||d==16||d==23||d||30)){
			cout<<"Friday"<<endl;
		}else if(m==10&&(d==3||d==10||d==17||d==24||d==31)){
			cout<<"Saturday"<<endl;
		}else if(m==10&&(d==4||d==11||d==18||d==25)){
			cout<<"Sunday"<<endl;
		}else if(m==10&&(d==5||d==12||d==19||d==26)){
			cout<<"Monday"<<endl;
		}else if(m==10&&(d==6||d==13||d==20||d==27)){
			cout<<"Tuesday"<<endl;
		}else if(m==10&&(d==7||d==14||d==21||d==28)){
			cout<<"Wednesday"<<endl;
		}else if(m==11&&(d==1||d==8||d==15||d==22||d==29)){
			cout<<"Sunday"<<endl;
		}else if(m==11&&(d==2||d==9||d==16||d==23||d==30)){
			cout<<"Monday"<<endl;
		}else if(m==11&&(d==3||d==10||d==17||d==24)){
			cout<<"Tuesday"<<endl;
		}else if(m==11&&(d==4||d==11||d==18||d==25)){
			cout<<"Wednesday"<<endl;
		}else if(m==11&&(d==5||d==12||d==19||d==26)){
			cout<<"Thursday"<<endl;
		}else if(m==11&&(d==6||d==13||d==20||d==27)){
			cout<<"Friday"<<endl;
		}else if(m==11&&(d==7||d==14||d==21||d==28)){
			cout<<"Saturday"<<endl;
		}else if(m==12&&(d==1||d==8||d==15||d==22||d==29)){
			cout<<"Tuesday"<<endl;
		}else if(m==12&&(d==2||d==9||d==16||d==23||d==30)){
			cout<<"Wednesday"<<endl;
		}else if(m==12&&(d==3||d==10||d==17||d==24||d||31)){
			cout<<"Thursday"<<endl;
		}else if(m==12&&(d==4||d==11||d==18||d==25)){
			cout<<"Friday"<<endl;
		}else if(m==12&&(d==5||d==12||d==19||d==26)){
			cout<<"Saturday"<<endl;
		}else if(m==12&&(d==6||d==13||d==20||d==27)){
			cout<<"Sunday"<<endl;
		}else if(m==12&&(d==7||d==14||d==21||d==28)){
			cout<<"Monday"<<endl;
		}
	}
}

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

int main() {
	int m, d;
	while (cin >> m >> d&&m + d) {
		int days[11] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30 };
		int sum = -1;
		for (int i = 0; i < m - 1; i++) {
			sum += days[i];
		}
		sum += d;
		switch (sum % 7) {
		case 0: cout << "Thursday\n"; break;
		case 1: cout << "Friday\n"; break;
		case 2: cout << "Saturday\n"; break;
		case 3: cout << "Sunday\n"; break;
		case 4: cout << "Monday\n"; break;
		case 5: cout << "Tuesday\n"; break;
		case 6: cout << "Wednesday\n"; break;
		}
	}
}