Go: package main

import "fmt"

func main() {
	days := [12]int{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
	weekday := [7]string{"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}

	for {
		var m, d int
		fmt.Scan(&m, &d)
		if m == 0 {
			break
		}

		for i := 0; i < m-1; i++ {
			d += days[i]
		}

		fmt.Println(weekday[d%7])
	}
}

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;
}

C++: 
import sys
import math

dayy = [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

def days(a, day):
    if a == 0:
        return day
    else:
        return days(a-1, day + dayy[a])


while 1:
    inp = raw_input().split()
    ii = int(inp[0])
    jj = int(inp[1])
    if ii == 0 and jj== 0:
        break
    ans = days(ii-1, 0) + jj
    ans = ans % 7
    if ans == 1:
        print "Thursday"
        continue
    if ans == 2:
        print "Friday"
        continue
    if ans == 3:
        print "Saturday"
        continue
    if ans == 4:
        print "Sunday"
        continue
    if ans == 5:
        print "Monday"
        continue
    if ans == 6:
        print "Tuesday"
        continue
    if ans == 0:
        print "Wednesday"
        continue