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<stdio.h>
int main()
{
int p[12]={31,29,31,30,31,30,31,31,30,31,30,31};
int M,D,sum;
while(1)
{
sum=0;
scanf("%d",&M);if(M==0)break;
scanf("%d",&D);
if(M==0)break;
for(int i=0;i<M-1;i++)
sum+=p[i];

sum+=D;

switch(sum%7)
{
case 4:
printf("Sunday\n");break;
case 5:
printf("Monday\n");break;

case 6:
printf("Tuesday\n");break;

case 0:
printf("Wednesday\n");break;

case 1:
printf("Tursday\n");break;

case 2:
printf("Friday\n");break;

case 3:
printf("Saturday\n");break;
}
}
return 0;
}

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

int main(void){
  int month[] = {31,29,31,30,31,30,31,31,30,31,30,31};
  string day[7] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", 
		   "Tuesday", "Wednesday"};

  int x, y, m, d, c;

  while(cin >> x >> y , x != 0){
    m = d = 1;
    c = 0;
    while(x !=m || y != d){
      d++;
      if(d > month[m - 1]){
	m++;
	d = 1;
      }
      c++;
      if(c == 7)
	c = 0;
    }
    cout << day[c] << endl;
  }

  return 0;
}

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

int main(void){
	while(1){
		int month, day;
		int days_from_new_year = 0;
		cin >> month >> day;
		if(month == 0 && day == 0) break;
		for(int i = 1; i < month; i++){
			if(i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) days_from_new_year += 31;
			else if(i == 4 || i == 6 || i == 9 || i == 12) days_from_new_year += 30;
			else if(i == 2) days_from_new_year += 29;
		}
		days_from_new_year += day;
		int mod = days_from_new_year % 7;
		if(mod == 0) cout << "Wednesday";
		else if(mod == 1) cout << "Thursday";
		else if(mod == 2) cout << "Friday";
		else if(mod == 3) cout << "Saturday";
		else if(mod == 4) cout << "Sunday";
		else if(mod == 5) cout << "Monday";
		else if(mod == 6) cout << "Tuesday";
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    int a,b;
    while (cin >>a>>b) {
        if(a==0 && b==0) break;
        
        else if(a==1){
            if((b+7)%7==1) cout<<"Thursday"<<endl; else if((b+7)%7==2) cout<<"Friday"<<endl;
            else if((b+7)%7==3) cout<<"Saturday"<<endl; else if((b+7)%7==4) cout<<"Sunday"<<endl;
            else if((b+7)%7==5) cout<<"Monday"<<endl; else if((b+7)%7==6) cout<<"Tuesday"<<endl;
            else cout<<"Wednesday"<<endl;
        }
        
        else if(a==2){
            if((b+7)%7==1) cout<<"Sunday"<<endl; else if((b+7)%7==2) cout<<"Monday"<<endl;
            else if((b+7)%7==3) cout<<"Tuesday"<<endl; else if((b+7)%7==4) cout<<"Wednesday"<<endl;
            else if((b+7)%7==5) cout<<"Thursday"<<endl; else if((b+7)%7==6) cout<<"Friday"<<endl;
            else cout<<"Saturday"<<endl;
        }
        else if(a==3){
            if((b+7)%7==1) cout<<"Monday"<<endl; else if((b+7)%7==2) cout<<"Tuesday"<<endl;
            else if((b+7)%7==3) cout<<"Wednesday"<<endl; else if((b+7)%7==4) cout<<"Thursday"<<endl;
            else if((b+7)%7==5) cout<<"Friday"<<endl; else if((b+7)%7==6) cout<<"Saturday"<<endl;
            else cout<<"Sunday"<<endl;
        }
        
        else if(a==4){
            if((b+7)%7==1) cout<<"Thursday"<<endl; else if((b+7)%7==2) cout<<"Friday"<<endl;
            else if((b+7)%7==3) cout<<"Saturday"<<endl; else if((b+7)%7==4) cout<<"Sunday"<<endl;
            else if((b+7)%7==5) cout<<"Monday"<<endl; else if((b+7)%7==6) cout<<"Tuesday"<<endl;
            else cout<<"Wednesday"<<endl;
        }
        
        else if(a==5){
            if((b+7)%7==1) cout<<"Saturday"<<endl; else if((b+7)%7==2) cout<<"Sunday"<<endl;
            else if((b+7)%7==3) cout<<"Monday"<<endl; else if((b+7)%7==4) cout<<"Tuesday"<<endl;
            else if((b+7)%7==5) cout<<"Wednesday"<<endl; else if((b+7)%7==6) cout<<"Thursday"<<endl;
            else cout<<"Saturday"<<endl;
        }
        
        else if(a==6){
            if((b+7)%7==1) cout<<"Tuesday"<<endl; else if((b+7)%7==2) cout<<"Wednesday"<<endl;
            else if((b+7)%7==3) cout<<"Thursday"<<endl; else if((b+7)%7==4) cout<<"Friday"<<endl;
            else if((b+7)%7==5) cout<<"Saturday"<<endl; else if((b+7)%7==6) cout<<"Sunday"<<endl;
            else cout<<"Monday"<<endl;
        }
        
        
        else if(a==7){
            if((b+7)%7==1) cout<<"Thursday"<<endl; else if((b+7)%7==2) cout<<"Friday"<<endl;
            else if((b+7)%7==3) cout<<"Saturday"<<endl; else if((b+7)%7==4) cout<<"Sunday"<<endl;
            else if((b+7)%7==5) cout<<"Monday"<<endl; else if((b+7)%7==6) cout<<"Tuesday"<<endl;
            else cout<<"Wednesday"<<endl;
        }
        
        else if(a==8){
            if((b+7)%7==1) cout<<"Sunday"<<endl; else if((b+7)%7==2) cout<<"Monday"<<endl;
            else if((b+7)%7==3) cout<<"Tuesday"<<endl; else if((b+7)%7==4) cout<<"Wednesday"<<endl;
            else if((b+7)%7==5) cout<<"Thursday"<<endl; else if((b+7)%7==6) cout<<"Friday"<<endl;
            else cout<<"Saturday"<<endl;
            
        }
        
        else if(a==9){
            if((b+7)%7==1) cout<<"Wednesday"<<endl; else if((b+7)%7==2) cout<<"Thursday"<<endl;
            else if((b+7)%7==3) cout<<"Friday"<<endl; else if((b+7)%7==4) cout<<"Saturday"<<endl;
            else if((b+7)%7==5) cout<<"Sunday"<<endl; else if((b+7)%7==6) cout<<"Monday"<<endl;
            else cout<<"Tuesday"<<endl;
        }
        
        else if(a==10){
            if((b+7)%7==1) cout<<"Friday"<<endl; else if((b+7)%7==2) cout<<"Saturday"<<endl;
            else if((b+7)%7==3) cout<<"Sunday"<<endl; else if((b+7)%7==4) cout<<"Monday"<<endl;
            else if((b+7)%7==5) cout<<"Tuesday"<<endl; else if((b+7)%7==6) cout<<"Wednesday"<<endl;
            else cout<<"Thursday"<<endl;
            
        }
        
        else if(a==11){
            if((b+7)%7==1) cout<<"Monday"<<endl; else if((b+7)%7==2) cout<<"Tuesday"<<endl;
            else if((b+7)%7==3) cout<<"Wednesday"<<endl; else if((b+7)%7==4) cout<<"Thursday"<<endl;
            else if((b+7)%7==5) cout<<"Friday"<<endl; else if((b+7)%7==6) cout<<"Saturday"<<endl;
            else cout<<"Sunday"<<endl;
        }
        else if(a==12){
            if((b+7)%7==1) cout<<"Wednesday"<<endl; else if((b+7)%7==2) cout<<"Thursday"<<endl;
            else if((b+7)%7==3) cout<<"Friday"<<endl; else if((b+7)%7==4) cout<<"Saturday"<<endl;
            else if((b+7)%7==5) cout<<"Sunday"<<endl; else if((b+7)%7==6) cout<<"Monday"<<endl;
            else cout<<"Tuesday"<<endl;
        }
        
        
        
    }
}

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


int main() {
  const int n_day[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  const string week_name[] = {
    "Wednesday",
    "Thursday",
    "Firday",
    "Saturday",
    "Sunday",
    "Monday",
    "Tuesday"
  };


  int m, d, sum=0;
  cin >> m >> d;
  while(m != 0 && d != 0) {
    m--;
    for(int i=0; i<m; i++) {
      sum += n_day[i];
    }
    sum += d;
    cout << week_name[sum%7] << endl;
    sum = 0;
    cin >> m >> d;
  }
  return 0;
}