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 <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int a, b;
int d[] = {31,29,31,30,31,30,31,31,30,31,30,31};
string s[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

signed main() {
	while (1) {
		cin >> a >> b;
		if (a==0) break;
		cout << s[accumulate(d,d+a-1,b+2)%7] << endl;
	}
}

C++: 
#include <iostream>

using namespace std;

const int days[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const char *daynames[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

int main() {
    while(true) {
        int m, d;
        cin >> m >> d;
        if(!m && !d) break;

        int daycnt = 0;
        for(int i = 1; i < m; ++i) daycnt += days[i];
        daycnt += d;
        cout << daynames[(daycnt+2) % 7] << endl;
    }
    return 0;
}

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

int main() {
  int k,m,d;
  string today[7]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
  int mon[12]={31,29,31,30,31,30,31,31,30,31,30,31};

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

    for(int i=0;m-1>i;i++) d+=mon[i];

    k=d%7+2;
    cout <<today[k]<<endl;
  
  }
}

C++: #include <iostream>
using namespace std;
 
int main(){
  int day30[4] = {4,6,9,11};
 
  while(1) {
  int m,d;
  cin >> m >> d;
  if(m == 0 && d == 0) break;
  int a = 1,b = 1,count = 0;
 
  while(1) {
 
    if(a == m && b == d) break;
     
    b++;
    count++;
 
    if(a == 2 && b == 30) {
      a++;
      b = 1;
    }
    else if(b == 31) {
      for(int i=0;i<4;i++) 
    if(day30[i] == a) {
      a++;
      b = 1;
      break;
    }
    }
    if( b == 32) {
      a++;
      b = 1;
    }
  }
   
  if(count % 7 == 4 ) cout <<"Monday"<<endl;
  else if(count % 7 == 5) cout << "Tuesday"<<endl;
  else if(count % 7 == 6) cout <<"Wednesday"<< endl;
  else if(count % 7 == 0) cout <<"Thursday"<< endl;
  else if(count % 7 ==1) cout << "Friday" << endl;
  else if(count % 7 ==2)cout << "Saturday" << endl;
  else if(count % 7 ==3) cout << "Sunday" << 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 (true) {
		cin >> m >> d;
		if (m==0 || d==0) break;
		
		int day = 3; // 2013/12/31 is Wednesday
		
		for (int i=0; i<m-1; i++) day += month[i];
		day += d;
		
		switch (day%7) {
		case 0 :
			cout << "Sunday"; break;
		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;
		}
		cout << endl;
	}
	
	return 0;
}

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

string data[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
int day[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int m, d;
	while(cin >> m >> d && m != 0){

		for(int i = 0; i < m - 1; ++i){
			d += day[i];
		}

		d -= 1;
		cout << data[(d + 3) % 7] << endl;
	}

	return 0;
}

C++: #include <cstdio>

int main() {
    int inm = 0;
    int ind = 0;
    while (scanf("%d %d", &inm, &ind) != EOF) {
        if ((inm == 0) && (ind == 0)) {
            break;
        }

        const int m[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
        int d = 2;

        for (int i = 0; i < inm; ++i) {
            for (int j = 0; j < m[i]; ++j) {
                if (d == 6) {
                    d = 0;
                } else {
                    d++;
                }

                if ((i == inm - 1) && (j == ind - 1)) {
                    goto end;
                }
            }
        }

        end:
        switch (d) {
        case 0:
            printf("Monday\n");
            break;
        case 1:
            printf("Tuesday\n");
            break;
        case 2:
            printf("Wednesday\n");
            break;
        case 3:
            printf("Thursday\n");
            break;
        case 4:
            printf("Friday\n");
            break;
        case 5:
            printf("Saturday\n");
            break;
        case 6:
            printf("Sunday\n");
            break;
    }
    }
    return 0;
}