Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func zeller(month, day int) int {
	year := 2004
	if month == 1 || month == 2 {
		year--
		month += 12
	}
	return (year + year/4 - year/100 + year/400 + (13*month+8)/5 + day)%7
}

func main() {
	scanner.Split(bufio.ScanWords)
	for {
		month := nextInt()
		day := nextInt()
		if month == 0 && day == 0{
			break
		}
		switch zeller(month, day) {
		case 0:
			fmt.Println("Sunday")
		case 1:
			fmt.Println("Monday")
		case 2:
			fmt.Println("Tuesday")
		case 3:
			fmt.Println("Wednesday")
		case 4:
			fmt.Println("Thursday")
		case 5:
			fmt.Println("Friday")
		case 6:
			fmt.Println("Saturday")
		}
	}
}

C++: #include <iostream>
using namespace std;
int main (){
    int a,b;
    while (cin >> a >>b){
        if(a==0 && b==0)
            break;
        switch (a){
            case 1 : break;
            case 2 : b+=31; break;
            case 3 : b+=60; break;
            case 4 : b+=91; break;
            case 5 : b+=121; break;
            case 6 : b+=152; break;
            case 7 : b+=182; break;
            case 8 : b+=213; break;
            case 9 : b+=244; break;
            case 10 : b+=274; break;
            case 11 : b+=305; break;
            case 12 : b+=335; break;
        }
        switch (b%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; break;
        }
    }
}

C++: #include <iostream>
using namespace std;
int sunday(int);
int monday(int);
int tuesday(int);
int wednesday(int);
int thursday(int);
int flyday(int);
int saturday(int);


int main(){
  int day ,month ,today;
  while(true){
    cin >> month >> day;
    if( month == 0 && day == 0 ){
      break;
    }

    if( month == 1 || month == 4 || month == 7 ){
      today = thursday(day);
    }
    
    if( month == 9 || month == 12 ){
      today = wednesday(day);
    }
    
    if( month == 3 || month == 11 ){
      today =  monday(day);
    }
    
    if( month == 6 ){
      today =  tuesday(day);
    }
    
    if( month == 2 || month == 8 ){
      today = sunday(day);
    }
    
    if( month == 10 ){
      today =  flyday(day);
    }
    
    if( month == 5 ){
      today =  saturday(day);
    }

    switch(today){
    case 0:
      cout << "Sunday" << endl;
      break;

    case 1:
      cout << "Monday" << endl;
      break;
    
    case 2:
      cout << "Tuesday" << endl;
      break;

    case 3:
      cout << "Wednesday" << endl;
      break;

    case 4:
      cout << "Thursday" << endl;
      break;
    
    case 5:
      cout << "Friday" << endl;
      break;

    case 6:
      cout << "Saturday" << endl;
      break;
    }
  }
  return 0;
}
  
int sunday(int day){
  int i ,today=0;
  for( i=1 ; i<day ; i++ ){
    today++;
    if( today == 7 ){
      today = 0;
    }
  }
  return today;
}


int monday(int day){
   int i ,today=1;
  for( i=1 ; i<day ; i++ ){
    today++;
    if( today == 7 ){
      today = 0;
    }
  }
  return today;
}


int tuesday(int day){
   int i ,today=2;
  for( i=1 ; i<day ; i++ ){
    today++;
    if( today == 7 ){
      today = 0;
    }
  }
  return today;
}


int wednesday(int day){
   int i ,today=3;
  for( i=1 ; i<day ; i++ ){
    today++;
    if( today == 7 ){
      today = 0;
    }
  }
  return today;
}


int thursday(int day){
    int i ,today=4;
  for( i=1 ; i<day ; i++ ){
    today++;
    if( today == 7 ){
      today = 0;
    }
  }
  return today;
}


int flyday(int day){
  int i ,today=5;
  for( i=1 ; i<day ; i++ ){
    today++;
    if( today == 7 ){
      today = 0;
    }
  }
  return today;
}


int saturday(int day){
    int i ,today=6;
  for( i=1 ; i<day ; i++ ){
    today++;
    if( today == 7 ){
      today = 0;
    }
  }
  return today;
}

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 + 6) % 7;
}

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

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

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

int main() {
    int m, d;
    while (cin >> m >> d, m && d) {
        int t = d;
        for (int i=0; i<m-1; ++i) {
            t += day[i];
        }
        cout << date[(t + 2) % 7] << endl;
    }
    return 0;
}

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

int main(){
	int m, d;
	int days[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	
	while( scanf(" %d %d", &m, &d)*m != 0 ){
		int i=0, c=0;
		while(i<=m-2){
			c+=days[i];
			++i;
		}
		c+=d;
	
		//printf("%d\n", c);
		if(c%7==1) printf("Thursday\n");
		else if(c%7==2) printf("Friday\n");
		else if(c%7==3) printf("Saturday\n");
		else if(c%7==4) printf("Sunday\n");
		else if(c%7==5) printf("Monday\n");
		else if(c%7==6) printf("Tuesday\n");
		else if(c%7==0) printf("Wednesday\n");
	}

	return 0;
}

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

int main(){
  int a,b,sum;
  while(1){
    cin >> a >> b;
    if(a==0&&b==0)break;
    sum=0;
    for(int i=1;i<a;i++){
      if(i==2)sum+=29;
      else if(i==4||i==6||i==9||i==11)sum+=30;
      else sum+=31;
    }
    sum+=b;
    if(sum%7==1)cout <<"Thursday"<<endl;
    if(sum%7==2)cout <<"Friday"<<endl;
    if(sum%7==3)cout <<"Saturday"<<endl;
    if(sum%7==4)cout <<"Sunday"<<endl;
    if(sum%7==5)cout <<"Monday"<<endl;
    if(sum%7==6)cout <<"Tuesdat"<<endl;
    if(sum%7==0)cout <<"Wednesday"<<endl;
  }
  return 0;
}