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<string>
using namespace std;
int main() {
	int a, b,h,  kazu;
	int  ans[1000];
	kazu = 0;
	while (1) {
		cin >> a >> b;
		if (a == 0) {
			goto a;
		}
		h = 0;
		kazu = kazu + 1;
		if (a >= 2) {
			h = 31;
		}
		if (a >= 3) {
			h = h + 29;
		}
		if (a >= 4) {
			h = h + 31;
		}
		if (a >= 5) {
			h = h + 30;
		}
		if (a >= 6) {
			h = h + 31;
		}
		if (a >= 7) {
			h = h + 30;
		}
		if (a >= 8) {
			h = h + 31;
		}
		if (a >= 9) {
			h = h + 31;
		}
		if (a >= 10) {
			h = h + 30;
		}
		if (a >= 11) {
			h = h + 31;
		}
		if (a >= 12) {
			h = h + 30;
		}
		h = h + b;
		while (h > 7) {
			h = h % 7;
		}
		ans[kazu] = h;
		
	}
a:;
	for (int x = 1; x <= kazu; x++) {
		if (ans[x] == 0) {
			cout << "Wednesday" << endl;
		}
			if (ans[x] == 1) {
				cout << "Thursday" << endl;
			}
		if (ans[x] == 2) {
			cout << "Friday" << endl;
		}
		if (ans[x] == 3) {
			cout << "Saturday" << endl;
		}
		if (ans[x] == 4) {
			cout << "Sunday" << endl;
		}
		if (ans[x] == 5) {
			cout << "Monday" << endl;
		}
		if (ans[x] == 6) {
			cout << "Tuesday" << endl;
		}
	}
}

C++: #include <stdio.h>

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

int main(){

  int i;
  for(i=1;i<12;i++) days[i] += days[i-1];

  int m,d;
  while(1){
    scanf("%d%d", &m, &d);
    if(m==0) break;
    
    d += days[m-1]+3;
    d %= 7;

    printf("%s\n", weeks[d]);
  }
}

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

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

int main(){
    int m, d;
    int day;

    while(1){
        day = 0;
        cin >> m >> d;
        if(m == 0 && d == 0) break;

        for(int i=1; i<m; i++){
            day += month_day[i-1];
        }
        day += d;

        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 <iostream>
#include <algorithm>
using namespace std;
int main(){
	int a,b,c;
	while(cin>>a>>b){
		if(a==0)break;
		if(a==1)c=b;
		if(a==2)c=31+b;
		if(a==3)c=60+b;
		if(a==4)c=91+b;
		if(a==5)c=121+b;
		if(a==6)c=152+b;
		if(a==7)c=182+b;
		if(a==8)c=213+b;
		if(a==9)c=244+b;
		if(a==10)c=274+b;
		if(a==11)c=305+b;
		if(a==12)c=335+b;
		if(c%7==1)cout<<"Thursday"<<endl;
		if(c%7==2)cout<<"Friday"<<endl;
		if(c%7==3)cout<<"Saturday"<<endl;
		if(c%7==4)cout<<"Sunday"<<endl;
		if(c%7==5)cout<<"Monday"<<endl;
		if(c%7==6)cout<<"Tuesday"<<endl;
		if(c%7==0)cout<<"Wednesday"<<endl;
	}
    return 0;
    }

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

int main()
{
	int month,day;
	int months[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
	string days[7] = {"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wndnessday"};
	while(cin >> month >> day)
	{
		if(month == 0) break;
		else
		{
			int sum = 0;
			for(int i=0;i<month-1;i++)
			{
				sum += months[i];
			}
			sum += day;
			cout << days[sum%7-1] << endl;
		}
	}
	return 0;
}

C++: //#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <math.h>
#include<algorithm>
#include <utility>
using namespace std;
int main() {//Thursda,Friday...0,1,2,3,4,5,6
	int month,day, today;//31%7=3
	int add=0;
	while (1) {
		cin >> month >> today;
		if (month == 0) {
			break;
		}
		if (month == 1) {
			add = 0;
		}
		else {
			for (int i = 1; i < month; i++) {
				if (i == 2) {
					add+=1;
				}
				else if (i % 2 == 0 && i < 8 || i == 11) {
					add += 2;
				}
				else {
					add += 3;
				}
			}
		}
		today += add;
		day = today%7;
		switch (day) {
		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;
		case 0:cout << "Wednesday" << endl; break;
		}
		add = 0;
	}
	return 0;
}