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>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
	int a, b;
	while(1){
		cin >> a >> b;
		if(a == 0 && b == 0) break;
		int date[13][32];
		for(int i = 0;i < 13;i++){
			for(int j = 0;j < 32;j++){
				date[i][j] = 9;
			}
		}
		int count = 0;
		for(int i = 1;i < 13;i++){
			if(i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12){
				for(int j = 1;j < 32;j++){
					date[i][j] = count;
					count++;
					if(count == 7) count = 0;
					//cout << date[i][j];
				}
				//cout << endl;
			}
			else if(i == 4 || i == 6 || i == 9 || i == 11){
				for(int j = 1;j < 31;j++){
					date[i][j] = count;
					count++;
					if(count == 7) count = 0;
				}
			}
			else if(i == 2){
				for(int j = 1;j < 30;j++){
					date[i][j] = count;
					count++;
					if(count == 7) count = 0;
				}
			}

		}

		if(date[a][b] == 0) cout << "Thursday" << endl;
		if(date[a][b] == 1) cout << "Friday" << endl;
		if(date[a][b] == 2) cout << "Saturday" << endl;
		if(date[a][b] == 3) cout << "Sunday" << endl;
		if(date[a][b] == 4) cout << "Monday" << endl;
		if(date[a][b] == 5) cout << "Tuesday" << endl;
		if(date[a][b] == 6) cout << "Wednesday" << endl;

	}
	return 0;
}

C++: #include<stdio.h>
int main()
{
int p[12]={31,29,31,30,31,30,31,31,30,31,30,31};
int M,D,sum;
while(1)
{
sum=0;
scanf("%d %d",&M,&D);
if(M==0)break;
for(int i=0;i<M;i++)
sum+=p[i];

sum+=D;

switch(sum%7)
{
case 0:
printf("Sunday\n");break;
case 1:
printf("Monday\n");break;

case 2:
printf("Tuesday\n");break;

case 3:
printf("Wednesday\n");break;

case 4:
printf("Tursday\n");break;

case 5:
printf("Friday\n");break;

case 6:
printf("Saturday\n");break;
}
}
return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
        int d[12] = {31, 29, 31, 30,
                                   31, 30, 31, 31,
                                   30, 31, 30, 31};
        string ans[7] = {"Thursday", "Friday", "Saturday", "Sunday",
                                         "Monday", "Tuesday", "Wednesday"};
        int mon, day;

        while (true) {
                cin >> mon >> day;
                if (!mon) {
                        break;
                }
                int sum = 0;
                for (int i = 0; i < mon - 1; i++) {
                        sum += d[i];
                }
                sum += day - 1;
                cout << ans[sum % 7] << endl;
        }


        return 0;
}

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

using namespace std;

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

int main()
{
  int day, month;
  while(1)
  {
    cin >> month >> day;
    if(!month)
      break;

    for(int i = 1; i < month; i++)
      day += monthdays[i];

    cout << days[day % 7] << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

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

int main(void) {
    int a, b, d;
    while (true) {
        cin >> a >> b;
        if (a == 0 && b == 0) break;
        d = 3;
        for (int m = 0; m < a - 1; m++) d += mdays[m];
        d += b - 1;
        cout << days[d % 7] << endl;
    }
    return 0;
}

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

const string day[] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};

int dd[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

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

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

int monthes[]={0,31,29,31,30,31,30,31,31,30,31,30,31};

std::string day[]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};

int main(void){
    int m,d,n;
    while(std::cin>>m>>d){
        if(m==0&&d==0) break;
        n=0;
        int i;
        for(i=1;i<m;i++) n+=monthes[i];
        n+=monthes[i]-d+1;
        std::cout<<day[n%7]<<std::endl;
    }
    return 0;
}

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

using namespace std;

int monthTable[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int date[13];
string dayTable[7] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};

void initialize(){
    date[0] = 0;
    date[1] = monthTable[1];
    for ( int i = 2; i <= 12; i++ ){
	date[i] = date[i-1] + monthTable[i];
    }
}

main(){
    initialize();
    int month, day;
    while( cin >> month >> day && month){
	cout << dayTable[(date[month-1]+day-1)%7] << endl;
    }
}

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

int day(int m, int d){
	if(m==1)return d;
	if(m==2)return 31+d;
	if(m==3)return 60+d;
	if(m==4)return 91+d;
	if(m==5)return 121+d;
	if(m==6)return 152+d;
	if(m==7)return 182+d;
	if(m==8)return 213+d;
	if(m==9)return 244+d;
	if(m==10)return 274+d;
	if(m==11)return 305+d;
	if(m==12)return 366-d;
}

int main(){
	while(1){
		int m,d;
		std::cin>>m>>d;
		if(m==0)return 0;
		std::string s;
		if(day(m,d)%7==1)s="Thursday";
		if(day(m,d)%7==2)s="Friday";
		if(day(m,d)%7==3)s="Saturday";
		if(day(m,d)%7==4)s="Sunday";
		if(day(m,d)%7==5)s="Monday";
		if(day(m,d)%7==6)s="Tuesday";
		if(day(m,d)%7==0)s="Wednesday";
		std::cout<<s<<std::endl;
	}
}

C++: #include <iostream>
#include <string>
#include <algorithm>
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 + accumulate(day, day + m - 1, 0);
        cout << date[(t + 2) % 7] << endl;
    }
    return 0;
}

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

using namespace std;

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

int main()
{
  int month, day;
  while (scanf("%d %d ", &month, &day) == 2) {
    if (month == 0 && day == 0) {break;}
    int sumday = 0;
    for (int i = 0; i < month - 1; i++) {
      sumday += mday[i];
    }
    sumday += day;
    cout << cal[(sumday + 2) % 7] << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int month, day, youbi;

	while(cin >> month >> day)
	{
		if(month == 0 && day == 0)    break;

		int year = 2004;
		
		if(month == 1){
			year = 2003;
			month = 13;
		}
		if(month == 2){
			year = 2003;
			month = 14;
		}

		year %= 100;

		youbi = (day + ((26*(month+1))/10) + year + (year/4) - 2*(year/100) + (year/100)/4);

		switch(youbi%7)
		{
			case 1: cout << "Sunday" << endl; break;
			case 2: cout << "Monday" << endl; break;
			case 3: cout << "Tuesday" << endl; break;
			case 4: cout << "Wednesday" << endl; break;
			case 5: cout << "Thursday" << endl; break;
			case 6: cout << "Friday" << endl; break;
			case 0: cout << "Saturday" << endl; break;
		}
	}

	return 0;
}