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<stdio.h>
 
int main(){
	int m, d, h[11], i;
	h[0] = h[2] = h[4] = h[6] = h[7] = h[9] = 31;
	h[3] = h[5] = h[8] = h[10] = 30;
	h[1] = 29;
	while(scanf("%d %d", &m, &d) != 0){
		if(m == 0 || d == 0) break;
		for(i = 0; i < m - 1; i++) d += h[i];
		if(d % 7 == 1) printf("Thursday\n");
		else if(d % 7 == 2) printf("Friday\n");
		else if(d % 7 == 3) printf("Saturday\n");
		else if(d % 7 == 4) printf("Sunday\n");
		else if(d % 7 == 5) printf("Monday\n");
		else if(d % 7 == 6) printf("Tuesday\n");
		else if(d % 7 == 0) printf("Wednesday\n");
	}
	return 0;
}

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

using namespace std;

int Month;
int Day;

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

int ans[12][31];
int main(int argc, char *argv[])
{
  while(scanf("%d %d",&Month,&Day)){
      int d = 3;
    if(Month == 0)
      break;
    for(int i = 0;i < 12;i++){
      for(int j = 0;j < days[i];j++){
	ans[i][j] = d%7;
	d++;
      }
    }
    cout <<data[ans[Month-1][Day-1]]<<endl;
  }
  return 0;
}

C++: #include <stdio.h>
int main(){
    int tuki,hi,youbi=4;
    while(1){
        scanf("%d %d",&tuki,&hi);
        if(tuki==0) break;
        switch(tuki){
            case 2: youbi=youbi+31+hi-1;
                break;
            case 3: youbi=youbi+60+hi-1;
                break;
            case 4: youbi=youbi+91+hi-1;
                break;
            case 5: youbi=youbi+121+hi-1;
                break;
            case 6: youbi=youbi+152+hi-1;
                break;
            case 7: youbi=youbi+182+hi-1;
                break;
            case 8: youbi=youbi+213+hi-1;
                break;
            case 9: youbi=youbi+244+hi-1;
                break;
            case 10: youbi=youbi+274+hi-1;
                break;
            case 11: youbi=youbi+305+hi-1;
                break;
            case 12: youbi=youbi+335+hi-1;
                break;
        }
        youbi=youbi%7;
        switch(youbi){
            case 0:puts("Sunday");
                break;
            case 1:puts("Monday");
                break;
            case 2:puts("Tuesday");
                break;
            case 3:puts("Wednesday");
                break;
            case 4:puts("Thursday");
                break;
            case 5:puts("Friday");
                break;
            case 6:puts("Saturday");
                break;
        }
        youbi=4;
    }
    return 0;
}

C++: #include <iostream>

int main(){
    int m, d, w = 3;
    int days[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    char *weekName[7] = {"Sunday", "Monday", "Tuesday", "Wednesday",
                         "Thursday", "Friday", "Saturday"};
    while(1){
        std::cin >> m >> d;
        if(!(m || d)){
            return 0;
        }
        for(int i = 1; i < m; i++){
            w += days[i - 1];
        }
        w += d; 
        std::cout << weekName[w % 7] << std::endl;
    }
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	VI day = { 31,29,31,30,31,30,31,31,30,31,30,31 };
	VS name = { "Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday" };
	while (true) {
		int x, y;
		cin >> x >> y;
		if (x == 0 && y == 0)break;

		int sum = 0;
		rep(i, x - 1)sum += day[i];
		sum += y;
		cout << name[(sum - 1) % 7] << endl;
	}
}

C++: #include <bits/stdc++.h>

using namespace std;

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

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&&d==0)break;

    for(int i=0;m-1>i;i++){

      if(m==1)break;
      else d+=mon[i];

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