Go: package main

import (
        "fmt"
)

func main() {
        var weeks = []string{"Thursday",
                "Friday",
                "Saturday",
                "Sunday",
                "Monday",
                "Tuesday",
                "Wednesday"}

        for {
                var m, d int
                _, err := fmt.Scanf("%d %d", &m, &d)
                if err != nil || m + d == 0 {
                        break
                }
                var days int

                for {
                        lm, ld := getLastDay(m, d)
                        if lm + ld == 0 {
                                break
                        }
                        days++
                        m = lm
                        d = ld
                }
                fmt.Println(weeks[days%7])
        }
}

func getLastDay(m int, d int) (lm int, ld int) {
        if m == 1 && d == 1 {
                return 0, 0
        }

        if d > 1 {
                return m, d-1
        } else {
                if m == 3 {
                        return m-1, 29
                }
                if m == 3 || m == 5 || m == 7 || m == 10 || m == 12 {
                        return m-1, 30
                } else {
                        return m-1, 31
                }
        }
}

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

int day(int month){
	switch(month){
		case 4:
		case 6:
		case 9:
		case 11:
			return 30;
			break;
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			return 31;
			break;
		case 2:
			return 29;
			break;
	}
}

int main(){
	int m, d, num;
	while(cin >> m >> d, m || d){
		num = 0;
		for(int i=1; i < m; i++){
			num += day(i);
		}
		num += d;
		switch(num % 7){
			case 1:
				cout << "Thursday" << endl;
				break;
			case 2:
				cout << "Friday" << endl;
				break;
			case 3:
				cout << "Saturday" << endl;
				break;
			case 4:
				cout << "Sunday" << endl;
				break;
			case 5:
				cout << "Monday" << endl;
				break;
			case 6:
				cout << "Tuesday" << endl;
				break;
			case 0:
				cout << "Wednesday" << endl;
		}
	}
}

C++: #include <algorithm>
#include <iostream>
#include <stdio.h>
#include <stack>

using namespace std;

int main(void){
    int month,day,ans;
    while(1){
        cin >> month >> day;
        if(month==0) break;
        if(month==1){
            ans=day;
        }
        if(month==2){
            ans=day+31;
        }
        if(month==3){
            ans=day+60;
        }
        if(month==4){
            ans=day+91;
        }
        if(month==5){
            ans=day+121;
        }
        if(month==6){
            ans=day+152;
        }
        if(month==7){
            ans=day+182;
        }
        if(month==8){
            ans=day+213;
        }
        if(month==9){
            ans=day+244;
        }
        if(month==10){
            ans=day+274;
        }
        if(month==11){
            ans=day+305;
        }
        if(month==12){
            ans=day+366;
        }
        ans=ans%7;
        if(ans==1) cout << "Thursday" << endl;
        if(ans==2) cout << "Frisday" << endl;
        if(ans==3) cout << "Saturday" << endl;
        if(ans==4) cout << "Sunday" << endl;
        if(ans==5) cout << "Monday" << endl;
        if(ans==6) cout << "Tuesday" << endl;
        if(ans==0) cout << "Wednesday" << endl;
    }
    return 0;
}

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

int main() {
    int mtod[]={0,31,60,91,121,152,182,213,244,274,305,335};
    string wd[]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
    while (1) {
        int m,d;
        cin>>m>>d;
        if (m==0)
            break;
        int day=mtod[m-1]+d;
        cout<<wd[day%7]<<endl;
    }
    return 0;
}

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

const int n_day[] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
const string name[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

int main() {
  int m, d;
  while(cin >> m >> d && (m|d)) {
    pair<int,int> end(m,d), date(1,1);
    int e = 4;
    while(date != end) {
      e = (e+1)%7;
      if(date.second == n_day[date.first]) {
	++date.first;
	date.second = 1;
      } else {
	++date.second;
      }
    }
    cout << name[e] << endl;
  }
  return 0;
}

C++: int main()
{
	char yobi[7][10]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
	int month,day;
	while(1){
		scanf("%d %d",&month,&day);
		if(month==0)
			break;
		for(int i=0;i<month;i++){
			switch(i){
				case 2:
					day+=29;
				case 4:
				case 6:
				case 9:
				case 11:
					day+=30;
				default:
					day+=31;
			}
		}
		printf("%s\n",yobi[day%7]);
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
#define reep(i,f,n) for(int i=f;i<(int)n;++i)
#define rep(i,n) reep(i,0,n)
int d[13][32];
int main()
{
    d[1][1]=4;
    reep(i,2,32){
        if(d[1][i-1]!=7)d[1][i]=d[1][i-1]+1;
        else d[1][i]=1;
    }
    d[2][1]=d[1][31]+1;
    reep(i,2,30){
        if(d[2][i-1]!=7)d[2][i]=d[2][i-1]+1;
        else d[2][i]=1;
    }
    d[3][1]=d[2][29]+1;
    reep(i,2,32){
        if(d[3][i-1]!=7)d[3][i]=d[3][i-1]+1;
        else d[3][i]=1;
    }
    d[4][1]=d[3][31]+1;
    reep(i,2,31){
        if(d[4][i-1]!=7)d[4][i]=d[4][i-1]+1;
        else d[4][i]=1;
    }
    d[5][1]=d[4][30]+1;
    reep(i,2,32){
        if(d[5][i-1]!=7)d[5][i]=d[5][i-1]+1;
        else d[5][i]=1;
    }
    d[6][1]=d[5][31]+1;
    reep(i,2,31){
        if(d[6][i-1]!=7)d[6][i]=d[6][i-1]+1;
        else d[6][i]=1;
    }
    d[7][1]=d[6][30]+1;
    reep(i,2,32){
        if(d[7][i-1]!=7)d[7][i]=d[7][i-1]+1;
        else d[7][i]=1;
    }
    d[8][1]=d[7][31]+1;
    reep(i,2,32){
        if(d[8][i-1]!=7)d[8][i]=d[8][i-1]+1;
        else d[8][i]=1;
    }
    d[9][1]=d[8][31]+1;
    reep(i,2,31){
        if(d[9][i-1]!=7)d[9][i]=d[9][i-1]+1;
        else d[9][i]=1;
    }
    d[10][1]=d[9][30]+1;
    reep(i,2,32){
        if(d[10][i-1]!=7)d[10][i]=d[10][i-1]+1;
        else d[10][i]=1;
    }
    d[11][1]=d[10][31]+1;
    reep(i,2,30){
        if(d[11][i-1]!=7)d[11][i]=d[11][i-1]+1;
        else d[11][i]=1;
    }
    d[12][1]=d[11][30]+1;
    reep(i,2,32){
        if(d[12][i-1]!=7)d[12][i]=d[12][i-1]+1;
        else d[12][i]=1;
    }
    while(1)
    {
        int m,day;
        cin>>m>>day;if(!m)return 0;
        const char* str[]={0,"Monday", "Tuesday", "Wednesday","Thursday", "Friday", "Saturday", "Sunday"};
        cout<<str[d[m][day]]<<endl;
    }
    return 0;
}

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

int main(){
	int mon, day, total;
	string s;

	while ( 1 ){
		cin >> mon >> day;
		if ( !mon ) break;

		total = day;
		for ( int i = 1; i < mon; ++i ){
			switch ( i ){
				case 1 : case 3 : case 5 : case 7 :
				case 8 : case 10 : case 12:
					total += 31;
					break;
				case 2 :
					total += 29;
					break;
				case 4 : case 6 : case 9 : case 11 :
					total += 30;
					break;
			}
		}

		switch ( total % 7 ) {
			case 0 : s = "Wednesday"; break;
			case 1 : s = "Thursday"; break;
			case 2 : s = "Friday"; break;
			case 3 : s = "Saturday"; break;
			case 4 : s = "Sunday"; break;
			case 5 : s = "Monday"; break;
			case 6 : s = "Tuesday"; break;
		}

		cout << s << endl;
	}

	return 0;
}

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

int main(){
  int m,d;
  int dom[12]={31,29,31,30,31,30,31,31,30,31,30,31};
  char w[7][10]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
  while(1){
    cin>>m>>d;
    if(m==0||d==0) break;
    int s=0;
    for(int i=0;i<m-1;i++) s += dom[i];
    cout<<w[(s+d)%7]<<endl;
  }
  return 0;
}