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 <cstdio>
#include <algorithm>
#include <functional>
#include <stack>
#include <cmath>
#include <map>
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define llong long long

int main() {
  int m,d;
  while(1) {
    scanf("%d %d", &m, &d);
    if(m == 0 && d == 0) break;
    int t = 3;
    if(m > 1) t += 31;
    if(m > 2) t += 29;
    if(m > 3) t += 31;
    if(m > 4) t += 30;
    if(m > 5) t += 31;
    if(m > 6) t += 30;
    if(m > 7) t += 31;
    if(m > 8) t += 31;
    if(m > 9) t += 30;
    if(m > 10) t += 31;
    if(m > 11) t += 30;
    t += d-1;
    switch(t%7) {
    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;
}

C++: #include<stdio.h>

void y(int x ){
	if(x == 0)
		puts("Thursday");
	else if(x == 1)
		puts("Friday");
	else if(x == 2)
		puts("Suturday");
	else if(x == 3)
		puts("Sunday");
	else if(x == 4)
		puts("Monday");
	else if(x == 5)
		puts("Tuesday");
	else if(x == 6)
		puts("Wednesday");
}

int main(void){
	int M,D;
	while(1){
		int date = 0,ans;
		int m[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
		
		scanf("%d%d", &M, &D);
		if(M == 0 && D  == 0)break;
		for(int i = 1; i <= 12 ; i++){
			for(int j = 1; j <= m[i-1]; j++){
				if(i == M && j == D){
					ans = date;
				}
//				printf("%d%dú",i,j);
//				y(date%7);
				date++;
			}
		}
		y(ans%7);
	}
	
	return 0;
}

C++: #include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cstdio>
#include <cctype>
#include <queue>
#include <complex>
#include <climits>

typedef long long ll;

using namespace std;

int GetDayOfWeek(int nYear, int nMonth, int nDay)
{
	if (nMonth == 1 || nMonth == 2) {
		nYear--;
		nMonth += 12;
	}
	return (nYear + nYear / 4 - nYear / 100 + nYear / 400 + (13 * nMonth + 8) / 5 + nDay) % 7;
}


int main(){
	int a, b;
	while(cin >> a >> b){
		string str;
		int s = GetDayOfWeek(2004, a, b);
		cout << s << endl;
		switch(s){
		case 0:
			str = "Sunday";
			break;
		case 1:
			str = "Monday";
			break;
		case 2:
			str = "Tuesday";
			break;
		case 3:
			str = "Wednesday";
			break;
		case 4:
			str = "Thursday";
			break;
		case 5:
			str = "Friday";
			break;
		case 6:
			str = "Saturday";
			break;
		}
	
	cout << str << endl;

	}

    return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF = INT_MAX/10;

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

int main() {
	int m, d;
	while(cin >> m >> d, m) {
		int res = 0;
		for(int i = 1; i < m; i++) {
			res += day[i-1];
		}
		res += (d-1);

		cout << days[res%7] << endl;
	}

	return 0;
}

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

int main(){
  int month[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
  for(int i=0;i<12;i++)month[i+1]+=month[i];
  vector<string> day(7);
  day[0] = "Sunday";
  day[1] = "Monday";
  day[2] = "Tuesday";
  day[3] = "Wednesday";
  day[4] = "Thursday";
  day[5] = "Friday";
  day[6] = "Saturday";

  int a,b;
  while(true){
    cin>>a>>b;
    if(!a&&!b)break;
    cout<<day[(month[a-1]+b+3)%7]<<endl;
  }
  return 0;
}

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

int main() {

  string week[7] = {
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday",
    "Sunday",
  };
  int end_day[13] = {-1,31,29,31,30,31,30,31,31,30,31,30,31};
  int month,day;
  while(cin >> month >> day) {
    if(month == 0) break;
    int today = 3; // because, 1/1 is Thursday
    for(int m = 1;m <= month;m++) {
      for(int d = 1;d <= end_day[m];d++) {
        if(m == month && d == day) break;
        today = (today + 1) % 7;
      }
    }
    cout << week[today] << 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 mon[13] ={0,0,31,60,91,121,152,182,213,244,274,305,335};

int main(){
	
	while(cin>>m>>d,!(m==0&&d==0)){
		
		d+=mon[m];
		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;
	
}