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 <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

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

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        int a,b;
        cin >> a >> b;
        if(a == 0) break;
        cout << s[zeller(2004, a, b)] << "\n";
    }
    return 0;
}

C++: #include <iostream>

const int days[12]={31,29,31,30,31,30,31,31,30,31,30,31};
const std::string str[7]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};

int m2d(int month)
{
	if(month==0)
		return 0;
	return days[month-1] + m2d(month-1);
}

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

		std::cout << str[(m2d(m-1)+d+4-1)%7] << std::endl;
	}
	return 0;
}

C++: #include <stdio.h>

int main(void){
	int month, day;
	int dday[12] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};
	int answer;
	while(1){
		scanf("%d %d", &month, &day);
		if(month == 0) break;

		answer = (dday[month -1] + day-1) % 7;
		switch(answer){
		case 0:
			puts("Thursday");
			break;
		case 1:
			puts("Friday");
			break;
		case 2:
			puts("Saturday");
			break;
		case 3:
			puts("Sunday");
			break;
		case 4:
			puts("Monday");
			break;
		case 5:
			puts("Tuesday");
			break;
		case 6:
			puts("Wednesday");
		}
	}	
	return 0;
}

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

int main()
{
	string days[]={
		"Mon",
		"Tues",
		"Wednes",
		"Thurs",
		"Fri",
		"Satur",
		"Sun"
	};
	int cal[12][31]={{0}};
	int today=3;
	for (int i=0; i<12; i++) {
		for (int j=0; j<31; j++) {
			cal[i][j]=today;
			++today%=7;
			if (i==3 || i== 5 || i==8 || i==10) {
				if (j==29) {
					break;
				}
			}
			else if (i==1) {
				if (j==28) {
					break;
				}
			}
		}
	}
	int a,b;
	for (cin >> a >> b; a; cin >> a >> b) {
		cout << days[cal[a-1][b-1]] << "day" << endl;
	}	
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
using namespace std;

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

int m,d;

int main(){
	
	while(cin>>m>>d,!(m==0&&d==0)){
		if(m==2){
			d+=31;
		}
		if(m==3){
			d+=60;
		}
		if(m==4){
			d+=91;
		}
		if(m==5){
			d+=121;
		}
		if(m==6){
			d+=152;
		}
		if(m==7){
			d+=182;
		}
		if(m==8){
			d+=213;
		}
		if(m==9){
			d+=246;
		}
		if(m==10){
			d+=276;
		}
		if(m==11){
			d+=307;
		}
		if(m==12){
			d+=337;
		}
		d = d%7;
		if(d==0) cout<<"Wednesday\n";
		if(d==1) cout<<"Thursday\n";
		if(d==2) cout<<"Friday\n";
		if(d==3) cout<<"Saturday\n";
		if(d==4) cout<<"Sunday\n";
		if(d==5) cout<<"Monday\n";
		if(d==6) cout<<"Tuesday\n";
	}
	return 0;
	
}

C++: #include <algorithm>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <functional>
#include <queue>
#include <string>
#include <map>
#include <vector>

using namespace std;

int main() {
  const char *ws[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
  int ms[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 
  for (int i = 2; i <= 12; i++)
    ms[i] += ms[i-1];
  for (;;) {
    int m, d;
    cin >> m >> d;
    if (!m && !d) return 0;
    cout << ws[(2+ms[m-1]+d)%7] << endl;
  }
  return 0;
}

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

int months[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
string days[7] = {"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wndnessday"};

int main()
{
	int month,day,sum = 0;
    
    while(cin >> month >> day,month || day)
	{
		for(int i=0;i<month;i++)
		{
	        sum += months[i-1];
		}
        sum += day -1;
		cout << days[sum%7] <<endl;
    }
	return 0;
}

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

int nd[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string wk[7] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};

int main(void){
  int m, d;
  while(cin >> m >> d && m && d){
    int sd = d;
    for(int i = 1; i < m; i++) sd += nd[i];
    cout << wk[sd % 7] << endl;
  }
  return 0;
}

C++: #include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define F first
#define S second
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl

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

int main(){
	li m,d;
	li acum=3;
	li day[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	
	while(1){
		acum=3;
		cin>>m>>d;
		if(min(m,d)==0)break;
		
		rep(i,m-1)acum+=day[i];
		acum+=d-1;
		cout<<yobi[acum%7]<<endl;
	}
	
	return 0;
}

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

using namespace std;

int main(void){
    for(;;){
        int m,d;
        int data[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
        cin>>m>>d;
        if(m==0&&d==0)break;
        for(int i=1;i<=m;i++){
            d+=data[i-1];
        }
        switch(d%7){
            case 0: cout << "Wednesday" << endl; break;
            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;
        }
    }
	return 0;
}