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;

const int DAYS_NUM[12] =
  {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const string days[7] = {
  "Monday", "Tuesday", "Wednesday", "Thursday",
  "Friday", "Saturday", "Sunday"
};

int main() {
  int m, d;
  string day;
  while(1) {
    cin >> m >> d;
    if (m == 0) break;
    for (int i = 0; i < m - 1; i++)
      d += DAYS_NUM[i];
    d = (d + 2) % 7;
    cout << days[d] << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
using namespace std;

int main(){
  int M[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  string w[7] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};

  int m, d;
  while( cin >> m >> d ){
    if( m == 0 || d == 0 ) break;

    int tmp = d;
    for(int i=0; i<m; i++) tmp += M[i];

    cerr << tmp << endl;
    cout << w[tmp%7] << endl;
  }

  return 0;
}

C++: #include <stdio.h>

static int days[] = {
  0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30
};

static char* week[] = {
  "Monday",
  "Tuesday",
  "Wednesday",
  "Thursday",
  "Friday",
  "Saturday",
  "Sunday"
};

int main(void)
{
  int i;
  for (i=0; i<11; ++i) {
    days[i+1] += days[i];
  }

  int month, day;
  while (scanf("%d %d", &month, &day) != EOF) {
    if (month==0 && day==0) {
      break;
    }

    day += days[month-1];
    day += 2;
    day %= 7;

    printf("%s\n", week[day]);
  }
  return 0;
}

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