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 a, b;
  int m[] = {0, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};
  int r = 0;
  while(1){
    cin >> a >> b;
    if(a == 0 && b == 0) break;
    r = (m[a] + b) % 7;
    switch (r)
    {
    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;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int main() {
    int m, d;
    int months[] = {31,29,31,30,31,30,31,31,30,31,30,31};
    while(cin >> m >> d, m + d) {
        REP(i,m-1) {
            d += months[i];
        }
        d -= 1;
        switch (d % 7) {
            case 0:
                cout << "Thursday" << endl;
                break;
                
            case 1:
                cout << "Friday" << endl;
                break;
                
            case 2:
                cout << "Saturday" << endl;
                break;
                
            case 3:
                cout << "Sunday" << endl;
                break;
                
            case 4:
                cout << "Monday" << endl;
                break;
                
            case 5:
                cout << "Tuesday" << endl;
                break;
                
            case 6:
                cout << "Wednesday" << endl;
                break;
                
            default:
                break;
        }
    }
    return 0;
}

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

const int t[14] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};

int main(void) {
	int m, d, a;

	while (cin >> m >> d, m) {
		a = (t[m-1] + d) % 7;
		if (a == 0) cout << "Wednesday";
		else if (a == 1) cout << "Thursday";
		else if (a == 2) cout << "Friday";
		else if (a == 3) cout << "Saturday";
		else if (a == 4) cout << "Sunday";
		else if (a == 5) cout << "Monday";
		else cout << "Tuesday";
		cout << endl;
	}

	return 0;
}

C++: #include<cstdio>

int main(){
	int a[] = {0,0,31,60,91,121,152,182,213,244,274,305,335,366};
	int m, d;
	char day[7][10] = {"Monday", "Tuesday", "Wednesday", "Thursday","Friday","Saturday","Sunday"};
	while(scanf("%d %d", &m, &d) + 1){
		printf("%s\n", day[(a[m] + d + 2) % 7]);
	}
}

C++: #include <iostream>
using namespace std;
void whatday(int year, int month, int date) {
  string day[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
  if(month == 1 || month == 2) {
	year--;
	month += 12;
  }
  int YEAR = year / 100;
  int h = (year + (year >> 2) - YEAR + (YEAR >> 2) + (13*month + 8)/5 + date) % 7;
  cout << day[h] << endl;
}
int main() {
  int month, day;
  while(cin >> month >> day) {
	if(month == 0 && day == 0) break;
	whatday(2004, month, day);
  }

  return 0;
}

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

using namespace std;

int main()
{
	int month = 0, day = 0, total_day = 0, week_num = 0;
	map<int, int> month_num;

	month_num[1] = 0;
	month_num[2] = 31;
	month_num[3] = 60;
	month_num[4] = 91;
	month_num[5] = 121;
	month_num[6] = 152;
	month_num[7] = 182;
	month_num[8] = 213;
	month_num[9] = 244;
	month_num[10] = 274;
	month_num[11] = 305;
	month_num[12] = 335;

	cin >> month >> day;

	while ( month * day != 0 )
	{
		total_day = month_num[month] + day-1;
		switch ( total_day % 7 )
		{
			case 0:
				cout << "Thursday" << endl;
				break;
			case 1:
				cout << "Friday" << endl;
				break;
			case 2:
				cout << "Saturday" << endl;
				break;
			case 3:
				cout << "Sunday" << endl;
				break;
			case 4:
				cout << "Monday" << endl;
				break;
			case 5:
				cout << "Tuesday" << endl;
				break;
			case 6:
				cout << "Wednesday" << endl;
				break;
			default:
				break;
		}
		cin >> month >> day;
	}

	return 0;
}

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

using namespace std;


char str[7][10] = {"Thursday", "Friday", "Saturday","Sunday", "Monday", "Tuesday", "Wednesday"};
int days[13] = {0, 0, 31, 60, 91, 121, 152, 182, 213, 243, 274, 304, 335}; 

int main() {
	int month, day;
	while (scanf("%d%d", &month, &day), month + day) {
		printf ("%s\n", str[(days[month] + day - 1) % 7]);
	}
	return 0;
}

C++: #include <stdio.h>
int main()
{
	char yobi[7][10]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
	int month,day;
	while(1){
		scanf("%d %d",&month,&day);
		if(month==0)
			break;
		for(int i=0;i<month;i++){
			switch(i){
				case 2:
					day+=29;
				case 4:
				case 6:
				case 9:
				case 11:
					day+=30;
				default:
					day+=31;
			}
		}
		printf("%s\n",yobi[day%7]);
	}
	return 0;
}

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

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

int main(void){
  int m, d;
  while(cin >> m >> d, m | d){
    while(1){
      m--;
      if(m > 0){
        d += da[m];
      }else{
        break;
      }
    }
    cout << day[d%7] << endl;
  }
  return 0;
}

C++: #include	<iostream>

using namespace std;

int main(void) {
	while(1) {
		int mon, day;
		cin >> mon;
		
		if( cin.eof() )		break;
		
		cin >> day;
		
		for(int i = 1; i < mon; i++) {
			switch(i) {
			case 2:
				day += 29;
				break;
			case 4:
			case 6:
			case 9:
			case 11:
				day += 30;
				break;
			default:
				day += 31;
				break;
			}
		}
		
		switch(day % 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;
		}
	}
	
	return 0;
}

C++: #include<stdio.h>
int main(){
  int a,b,s,i;
  int m[12]={31,29,31,30,31,30,31,31,30,31,30,31};
  while(1){ 
 scanf("%d%d",&a,&b);
 if(a==0&&b==0)break;
 s=b;
 for(i=0;i<a-1;i++)s+=m[i];
 if(s%7==1)printf("Thursday\n");
 else if(s%7==2)printf("Friday\n");
 else if(s%7==3)printf("Saturday\n");
 else if(s%7==4)printf("Sunday\n");
 else if(s%7==5)printf("Monday\n");
 else if(s%7==6)printf("Tuesday\n");
 else if(s%7==0)printf("Wednesday\n");
  }
  return 0;
}