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>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <iomanip>
using namespace std;
int main(){
  int m,d,mlist[12]={31,29,31,30,31,30,31,31,30,31,30,31},dsum;
  string res;
  while(cin>>m>>d){
    dsum=0;
    if(!m)return 0;
    for(int i=0;i<m;i++){
      dsum+=(i+1!=m)?mlist[i]:d;
    }
    //1 Thur 2 Fri 3 Satu 4 Sun 5 Mon 6 Tues 0 Wed
    switch(dsum%7)
      {
      case 0:
	res="Wednesday";
	break;
      case 1:
	res="Thursday";
	break;
      case 2:
	res="Friday";
	break;
      case 3:
	res="Saturday";
	break;
      case 4:
	res="Sunday";
	break;
      case 5:
	res="Monday";
	break;
      case 6:
	res="Tuesday";
	break;
      }
    cout<<res<<endl;
  }
}

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

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int const MOD = 1000000007;

int dayOfTheWeek( int y, int m, int d )
{
    if( m < 3 ) {
        y--; m += 12;
    }
    return ( y + y/4 - y/100 + y/400 + ( 13*m + 8 )/5 + d )%7;
}

int main() {
    string dayname[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
    int m,d;
    while(cin >> m, m) {
        cin >> d;
        cout << dayname[dayOfTheWeek(2016,m,d)] << endl;
    }
    return 0;
}

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

int main(){
	int month[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	int m,d;
	while(cin>>m>>d,m+d){
		int sum=d;
		for(int i=0;i<m-1;i++){
			sum+=month[i];
		}	
		switch(sum%7){
			case 1:cout<<"Thursday";break;
			case 2:cout<<"Friday";break;
			case 3:cout<<"Saturday";break;
			case 4:cout<<"Sunday";break;
			case 5:cout<<"Monday";break;
			case 6:cout<<"Tuesday";break;			
			case 0:cout<<"Wednesday";break;
		}
		cout<<endl;
		
	}
}

C++: #include <iostream>
using namespace std;
int main(){
	int m,d;
	while(cin>>m>>d){
		if(!m) break;
		int daym[12]={0,31,60,91,121,152,183,213,244,274,305,335};
		int wd = (daym[m-1] + d + 2)%7;
		switch(wd){
		case 0:
			cout <<"Monday"<<endl;
			break;
		case 1:
			cout<<"Tuesday"<<endl;
			break;
		case 2:
			cout<<"Wednesday"<<endl;
			break;
		case 3:
			cout<<"Thursday"<<endl;
			break;
		case 4:
			cout<<"Friday"<<endl;
			break;
		case 5:
			cout<<"Saturday"<<endl;
			break;
		case 6:
			cout<<"Sunday"<<endl;
			break;
		}
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<list>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

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

int b[13] = { 0,31,29,31,30,31,30,31,31,30,31,30,31 };

int main() {
	for (int m, d; cin >> m >> d&&m;) {
		while (m)
			d += b[--m];
		cout << a[(d - 1 + 3) % 7] << endl;
	}
	return 0;
}

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

using namespace std;
 
int main(){
	int m[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	string d[]={"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

	int x,y;

	while(scanf("%d %d", &x, &y) != EOF){
		if(0==x) break;
		int c=2;
		while(--x) c+=m[x];

		c+=y;
		cout<< d[c%7]<<endl;
	}

    return 0;
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)

const int month[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30};
int main()
{
  int m, d, cntdays = 0;
  
  while (cin >> m >> d, m + d){
    cntdays = month[m - 1] + d;
    switch (cntdats % 7){
      case 1:
        cout << Monday;
        break;
      case 2:
        cout << Tuesday;
        break;
      case 3:
        cout << Wednesday;
        break;
      case 4:
        cout << Thursday;
        break;
      case 5:
        cout << Friday;
        break;
      case 6:
        cout << Saturday;
        break;
      case 0:
        cout << Sunday;
        break;
      cout << endl;
    }
  }
}

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

int week(int m,int d){

  struct tm t;
  t.tm_year  = 104; // 2004 - 1900
  t.tm_mon   = m-1;
  t.tm_mday  = d;
  t.tm_hour  = 0;           
  t.tm_min   = 0;               
  t.tm_sec   = 0;               
  t.tm_isdst = -1;
  
  if (mktime(&t) == -1)
	return (-1);
  return(t.tm_wday);
}

int main(){
  int m,d;
  static string w[] = {"Sunday","Monday","Tuesday","Wednesday",
					   "Thursday","Friday","Saturday"};
  while(cin >> m >> d,m||d){
  cout << w[week(m,d)] << endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int dayl[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
  int today[2];
  int dayt=0;
  int ans;
  while(cin>>today[0]>>today[1]){
    if(today[0]==0&&today[1]==0) break;
    for(int i=0;i<today[0];i++) dayt += dayl[i];
    dayt += today[1];
    ans = dayt % 7;
    if(ans==1) cout << "Thursday" << endl;
    else if(ans==2) cout << "Friday" << endl;
    else if(ans==3) cout << "Saturday" << endl;
    else if(ans==4) cout << "Sunday" << endl;
    else if(ans==5) cout << "Monday" << endl;
    else if(ans==6) cout << "Tuesday" << endl;
    else  cout << "Wednesday" << endl;
    dayt = 0;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
	int i;
	int a, b;
	int day=0;
	int t;

	cin >> a;

	while(a != 0){
		if(a=1){
			day = day;
		}
		if(a=2){
			day = day + 31;
		}
		if(a=3){
			day = day + 60;
		}
		if(a=4){
			day = day + 91;
		}
		if(a=5){
			day = day + 121;
		}
		if(a=6){
			day = day + 152;
		}
		if(a=7){
			day = day + 182;
		}
		if(a=8){
			day = day + 213;
		}
		if(a=9){
			day = day + 244;
		}
		if(a=10){
			day = day + 274;
		}
		if(a=11){
			day = day + 305;
		}
		if(a=12){
			day = day + 335;
		}

		cin >> b;
		day = day + b;

		t = day % 7;
		if(t=1){
			cout << "Wednesday" << endl;
		}
		if(t=2){
			cout << "Thersday" << endl;
		}
		if(t=3){
			cout << "Friday" << endl;
		}
		if(t=4){
			cout << "Saturday" << endl;
		}
		if(t=5){
			cout << "Sunday" << endl;
		}
		if(t=6){
			cout << "Monday" << endl;
		}
		else{
			cout << "Tuesday" << endl;
		}
	}


}