Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
	"time"
)

var sc = bufio.NewScanner(os.Stdin)

//Sliceconvtoi ...
func Sliceconvtoi() []int {
	strs := strings.Split(sc.Text(), " ")

	var ints []int
	var x int

	for _, s := range strs {
		x, _ = strconv.Atoi(s)
		ints = append(ints, x)
	}

	return ints
}

func main() {
	for sc.Scan() {
		i := Sliceconvtoi()

		if i[0] == 0 && i[1] == 0 {
			break
		}

		m := time.Month(i[0])
		d := i[1]
		t := time.Date(2004, m, d, 0, 0, 0, 0, time.Local)
		fmt.Println(t.Weekday())
	}

}

C++: #include <iostream>

void displayDate(int index) {
  int i = (7 + index - 1) % 7 ;

  if (i == 0) {
    std::cout << "Sunday" << std::endl;
  } else if (i == 1) {
    std::cout << "Monday" << std::endl;
  } else if (i == 2) {
    std::cout << "Tuesday" << std::endl;
  } else if (i == 3) {
    std::cout << "Wednesday" << std::endl;
  } else if (i == 4) {
    std::cout << "Thursday" << std::endl;
  } else if (i == 5) {
    std::cout << "Friday" << std::endl;
  } else if (i == 6) {
    std::cout << "Saturday" << std::endl;
  }
}

int main() {
  while (true) {
    int m, d;
    std::cin >> m;
    std::cin >> d;

    if (m == 0 && d == 0) {
      break;
    } else if (m == 1) {
      displayDate(d + 4);
    } else if (m == 2) {
      displayDate(d + 0);
    } else if (m == 3) {
      displayDate(d + 1);
    } else if (m == 4) {      
      displayDate(d + 4);
    } else if (m == 5) {
      displayDate(d + 6);
    } else if (m == 6) {
      displayDate(d + 2);
    } else if (m == 7) {
      displayDate(d + 4);
    } else if (m == 8) {
      displayDate(d + 0);
    } else if (m == 9) {
      displayDate(d + 3);
    } else if (m == 10) {
      displayDate(d + 5);
    } else if (m == 11) {
      displayDate(d + 1);
    } else if (m == 12) {
      displayDate(d + 3);
    }
  }

  return 0;
}

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

int main(void){
  int month[] = {31,29,31,30,31,30,31,31,30,31,30,31};
  string day[7] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", 
		   "Tuesday", "Wednesday"};

  int x, y, m, d, c;

  while(cin >> x >> y , x != 0){
    m = d = 1;
    c = 0;
    while(x !=m || y != d){
      d++;
      if(d > month[m - 1]){
	m++;
	d = 1;
      }
      c++;
      if(c == 7)
	c = 0;
      cout << ' ' << c << endl;
    }
  }

  return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

constexpr int zeller(int y, int m, const int &d) {
  if (m == 1 || m == 2) y--, m += 12;
  int k = y % 100, j = y / 100;
  return (d + 13 * (m + 1) / 5 + k + k / 4 + j / 4 + 5 * j) % 7;
}

void solve() {
  int m, d;
  string t[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
  while (cin >> m >> d, m) cout << t[zeller(2014, m, d)] << endl;
}

C++: #include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>

using namespace std;

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

typedef vector<int> vi;

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

	reep(i, 1, 12)
		days[i] += days[i-1];

	int m, d;
	while(scanf("%d%d", &m, &d), m&&d){
		puts(strs[(days[m-1]+d-1)%7]);
	}

	return 0;
}

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

class Days{
	string week;
public:
	Days() : week("Thursday"){}
	void calcDays(int,int);
	int monthToDays(int);
	void calcWeek(int);
	void setWeek(int);
	const string getWeek(void);
};

int Days::monthToDays(int month){
	if(month == 2)
		return 29;//うるう年
	if(month == 4 || month == 6 || month == 9 || month == 11)
		return 30;
	return 31;
}

void Days::calcDays(int month,int days){
	week = ("Thursday");//コンストラクタで初期化済みだが念のために
	int day = 0;//1月1日から何日経ったか
	for(int i = 1; i < month; i++){
		day += monthToDays(i);
	}
	day += (days - 1);
	calcWeek(day);
}

void Days::calcWeek(int day){
	setWeek(day %= 7);
}

const string Days::getWeek(void){
	return week;
}

void Days::setWeek(int day){
	switch(day){
	case 0:
		week = "Thursday";
		break;
	case 1:
		week = "Friday";
		break;
	case 2:
		week = "Saturday";
		break;
	case 3:
		week = "Sunday";
		break;
	case 4:
		week = "Monday";
		break;
	case 5:
		week = "Tuesday";
		break;
	case 6:
		week = "Wednesday";
		break;
	}
}

int main(){
	Days d;
	int month,day;
	while(1){
		cin >> month >> day;
		if(month == 0 || day == 0)
			break;
		d.calcDays(month,day);
		cout << d.getWeek() << endl;
	}
	return 0;
}

C++: 
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0027&lang=jp

#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 = 2004;
	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 < 3){ year--; month_+=12; }
		if(month_ == 14){ day += 1; }
		int w = ((year + (year/4) - (year/100) + (year/400) + (((13 * month_) + 8)/5) + day) % 7);
		cout << week[w] << endl;
	}
	
	return 0;
}