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

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

int main(){
  int a,b,WD;
  while(cin>>a>>b){
    if(a==0){WD=8;break;}
    else if ((a==1)||(a==4)||(a==7))WD=(b+3)%7;
    else if ((a==2)||(a==8))WD=(b+6)%7;
    else if ((a==3)||(a==11))WD=b%7;
    else if (a==5)WD=(b+5)%7;
    else if (a==6)WD=(b+1)%7;
    else if ((a==9)||(a==12))WD=(b+2)%7;
    else if (a==10)WD=(b+4)%7;
    if(WD==0){
      cout <<"Sunday"<<endl;
    }
    else if(WD==1){
      cout <<"Monday"<<endl;
    }
    else if(WD==2){
      cout <<"Tuesday"<<endl;
    }
    else if(WD==3){
      cout <<"Wednesday"<<endl;
    }
    else if(WD==4){
      cout <<"Thursday"<<endl;
    }
    else if(WD==5){
      cout <<"Friday"<<endl;
    }
     else if(WD==6){
      cout <<"Saturday"<<endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
 
string week[7]={"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
 
int main(){
    int m, d, y;
    while(cin>>m>>d&&m!=0){
        y=2004;
        if(m<3){
            y--;
            m=m+12;
        }
        cout<<week[(y+(y/4)-(y/100)+(y/400)+(((13*m+8)/5)+d))%7]<<"\n";
// ツェラーの公式
    }
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define all(c) (c).begin(), (c).end()

using namespace std;
template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, T b) { if(b < a) a = b; }

int main() {
	int year = 2014;
	int month,day;
	string week[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

	while(true) {
		cin >> month >> day;
		if (month == 0 && day == 0) { break; }
		int month_ = month;
		if(month == 1) month_ = 13;
		if(month == 2) month_ = 14;
		int w = ((year + year/4 - year/100 + year/400 + (13 * month_ + 8)/5 + day) % 7);
		cout << week[w] << endl;
	}

	return 0;
}

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

int main(){
  int m,d;
  int cnt;
  string days[7]={"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
  while(1){
    cnt = 0;
    cin >> m >> d;
    if(m == 0 && d == 0) break;
    cnt += d;
    for(m--;m>0;m--){
      switch (m){
      case 4:
      case 6:
      case 9:
      case 11:
	cnt += 30;
	break;
      case 2:
	cnt += 29;
	break;
      default:
	cnt += 31;
	break;
      }
    }
    cout << days[cnt%7-1] << endl;
  }
}

C++: #include <cstdio>
#include <iostream>

using namespace std;

int main(){
	int days[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
	char week2[7][10] = {"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};

	int month,day;
	int sum;

	cin >> month >> day;
	while((month != 0) && (day != 0)){
		sum = 0;
		for(int i=0 ;i < month - 1;i++){
			sum += days[i];
		}
		sum += day;

		switch(sum % 7){
			case 1:
				printf("%s\n",week2[0]);
				break;

			case 2:
				printf("%s\n",week2[1]);
				break;

			case 3:
				printf("%s\n",week2[2]);
				break;

			case 4:
				printf("%s\n",week2[3]);
				break;

			case 5:
				printf("%s\n",week2[4]);
				break;

			case 6:
				printf("%s\n",week2[5]);
				break;

			case 0:
				printf("%s\n",week2[6]);
				break;

		}

		cin >> month >> day;
	}
}