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>
using namespace std;
int main(void)
{
  int m, d;
  
  while(1) {
    cin >> m >> d;
    if(m == 0) break;
    
    for(int i = m ; i > 1 ; i--) {
      if(i-1 == 4 || i-1 == 6 || i-1 == 9 || i-1 == 11) d += 30;
      else if(i-1 == 2) d += 29;
      else if(i-1 == 1 || i-1 == 3 || i-1 == 5 || i-1 == 7 || i-1 == 8 || i-1 == 10) d += 31;
    }
    
    if(d % 7 == 1) cout << "Thursday" << endl;
    if(d % 7 == 2) cout << "Friday" << endl;
    if(d % 7 == 3) cout << "Saturday" << endl;
    if(d % 7 == 4) cout << "Sunday" << endl;
    if(d % 7 == 5) cout << "Monday" << endl;
    if(d % 7 == 6) cout << "Tuesday" << endl;
    if(d % 7 == 7) cout << "Wednesday" << endl;
  }
  return 0;
}

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

int main(){
  for (;;) {
    int m, d;
    cin >> m >> d;
    if (m == 0) break;

    vector<int> day = {31, 29, 31, 30, 31, 30, 31, 30, 31, 30, 30, 31};
    int tmp = d;
    for (int i = 0; i < m - 1; i++) {
      tmp += day.at(i);
    }

    int ans = tmp % 7;
    vector<string> week = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};
    cout << week.at(ans) << endl;
  }
}

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

using namespace std;

int main(int argc, char *argv[]) {
  vector<string> result;
  int m, d;
  int mday[12] = {31, 29, 31, 30, 31, 30,
                  31, 31, 30, 31, 30, 31};

  while (true) {
    cin >> m >> d;
    if (m == 0 && d == 0)
      break;
    int days = 0;
    for (int i = 1; i < m; i++)
      days += mday[i-1];
    days += d;
    days %= 7;
    if (days == 1)
      result.push_back("Thursday");
    else if (days == 2)
      result.push_back("Friday");
    else if (days == 3)
      result.push_back("Saturday");
    else if (days == 4)
      result.push_back("Sunday");
    else if (days == 5)
      result.push_back("Monday");
    else if (days == 6)
      result.push_back("Tuesday");
    else
      result.push_back("Wednesday");
  }

  for (int i = 0; i < result.size(); i++)
    cout << result[i] << endl;
  return 0;
}

C++: #include <iostream>

using namespace std;


int totalDate(int month, int date)
{
	static const int MONTH[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

	int sum = 0;
	for(int i = 0; i < month-1; i++)
		sum += MONTH[i];

	return sum + date;
}

const char* day(int total_date)
{
	static const char* DAY[] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};

	return DAY[(total_date-1)%7];
}

int main()
{
	while(true)
	{
		int month, date;
		cin >> month >> date;

		if(month == 0)
			break;

		cout << day(totalDate(month, date)) << endl;
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
#include<cstdio>
int main(){
  int year[12]={31,29,31,30,31,30,31,31,30,31,30,31};
  int month,day,ans;
  while(1){
    cin>>month>>day;
    if(!month && !day)break;
    ans=0;
    for(int i=1;i<month;i++){
      ans+=year[i-1];
    }
    ans+=day;
    switch (ans%7){
    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;
	break;
    case 0: cout<<"Wednesday"<<endl;
	break;
    }
  }
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,n) for(long long int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long ll;
typedef vector<long long int> vi;
typedef vector<long long int>::iterator vit;

int main(){
	int m, d, c = 0;
	bool f = 0;
	int a[13] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	while (cin >> m >> d){
		if (m == 0)break;
		for (int i = 0; i < m; i++){
			for (int j = 0; j < a[i]; j++){
				c++;
				if (i == m - 1 && j == d - 1){
					f = 1;
					break;
				}
			}
			if (f)break;
		}
		c = c % 7;
		if (c == 1){
			cout << "Thursday\n";
		}
		else if (c == 2){
			cout << "Friday\n";
		}
		else if (c == 3){
			cout << "Saturday\n";
		}
		else if (c == 4){
			cout << "Sunday\n";
		}
		else if (c == 5){
			cout << "Monday\n";
		}
		else if (c == 6){
			cout << "Tuesday\n";
		}
		else {
			cout << "Wednesday\n";
		}
		c = 0;
		f = 0;
	}
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

const int days[12] = {
  31,29,31,30,
  31,30,31,31,
  30,31,30,31
};

const char *date[7] = {
  "Monday",
  "Tuesday",
  "Wednesday",
  "Thursday",
  "Friday",
  "Saturday",
  "Sunday"
};

int ans[12][31];

int main(){
  int d = 3;
  REP(i,12){
    REP(j,days[i]){
      ans[i][j] = (d++)%7;
    }
  }
  int a,b;
  while(cin>>a>>b,a)
    cout << date[ans[a-1][b-1]] << endl;

  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 % 7 - 1 + 3] << endl;
	}
	return 0;
}

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

int main()
{
  int m, d;
  while (1){
    cin >> m >> d;
    if (m == 0){
      break;
    }
    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 += 244;
    }
    if (m == 10){
      d += 274;
    }
    if (m == 11){
      d += 305;
    }
    if (m == 12){
      d += 335;
    }

    if (d % 7 == 0){
      cout << "Wednesday";
    }
    else if (d % 7 == 1){
      cout << "Thursday";
    }
    else if (d % 7 == 2){
      cout << "Friday";
    }
    else if (d % 7 == 3){
      cout << "Saturday";
    }
    else if (d % 7 == 4){
      cout << "Sunday";
    }
    else if (d % 7 == 5){
      cout << "Monday";
    }
    else {
      cout << "Tuesday";
    }
    cout << endl;
  }

  return 0;
}