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 <fstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

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

  int m, d;
  while (true) {
    cin >> m >> d;
    if (!(m|d)) break;
    int n = first;
    for (int i = 0; i < m-1; i++) {
      n += year[i];
    }
    n += d-1;

    n %= 7;
    cout << day[n] << endl;
  }
}

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

int m,d;
int data[] = {31,29,31,30,31,30,31,31,30,31,30,31};
string day[] = {"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};

int main(){
	while(cin >> m >> d){
		if(m == 0) break;

		for(int i = 0; i < m - 1; i++){
			d+=data[m];
		}
		cout << day[(d-1)%7] << endl;
	}
}

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

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

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

C++: #include <iostream>

using namespace std;


int main()
{
    int m[50],d[50];
    int x = 0;
    string Day[7] = {"Thursday", "Friday","Saturday","Sunday","Monday", "Tuesday", "Wednesday"};
    int BanyakHari[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
    int DayinBetween = 0;
    string ThatDayIs[50];

    do
    {
        cin >> m[x] >> d[x];
        if((m[x] == 0) && (d[x] == 0))
        {
            break;
        }
        //Check banyak hari antara 1 Januari - Input
        for(int y = 0; y < m[x]-1; y++)
        {
            DayinBetween = DayinBetween + BanyakHari[y];
        }
        DayinBetween = DayinBetween + d[x] - 1;

        //Kurangi sampai < 7
        while(true)
        {
            if(DayinBetween >= 7)
            {
                DayinBetween = DayinBetween - 7;
            }
            else
            {
                break;
            }
        }

        ThatDayIs[x] = Day[DayinBetween];

        x++;
    }
    while(x < 50);

    for(int z = 0; z < x; z++)
    {
        cout << ThatDayIs[z] << endl;
    }


}

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

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

int from_1_1(int m, int d) 
{
    int day_from_1_1 = d;
    for (int i = 0; i < m; i++) {
        day_from_1_1 += days[i];
    }
    return day_from_1_1;
}

int main(void)
{
    int m, d;
    string day;
    while (cin >> m >> d) {
        if (m == 0 && d == 0) break;
        switch ( from_1_1(m, d) % 7 ) {
            case 1:
                day = "Thursday";
                break;
            case 2:
                day = "Friday";
                break;
            case 3:
                day = "Saturday";
                break;
            case 4:
                day = "Sunday";
                break;
            case 5:
                day = "Monday";
                break;
            case 6:
                day = "Tuesday";
                break;
            case 0:
                day = "Wednesday";
                break;
            default: // DO_NOTHING
                break;
        }
        cout << day << endl;
    }
    return 0;
}

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

int howmany(int);

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

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

		for (int i = 1;i < month; i++) {
			total += howmany(i);
		}
		total += day;
		mod = total % 7;

		switch (mod) {
		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;
		default:
			break;
		}
	}

	return 0;
}

int howmany(int month) {
	if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
		return 31;
	}
	else if (month == 2) {
		return 29;
	}
	else {
		return 30;
	}
}

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

int months[] = {31,29,31,30,31,30,31,31,30,31,30,31};
string days[] = {"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wndnessday"};

int main()
{
	int month,day,sum = 0;
    
    while(cin >> month >> day,month || day)
	{
		for(int i=0;i<month;i++)
		{
	        sum += months[i-1];
		}
        sum += day -1;
		cout << days[sum%7] <<endl;
    }
	return 0;
}

C++: #include <stdio.h>

int main(void)
{
	int MONTH[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	
	char DAYS[7][10] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};
	
	int month, date, i;
	
	while(scanf("%d %d",&month, &date)){
		getchar();
		if(month == 0){
			break;
		}
		
		int total = 0;
		for(i = 1;i < month;i++){
			total += MONTH[i - 1];
		} 
		
		total += date -1 ;
		
		//printf("%d\n",total);
		printf("%s\n",DAYS[total % 7]);
	}
	
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, init, n) for(int i = init; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

int main()
{
    vector<int> day = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    REP(i, 1, 12) day[i] += day[i - 1];

    int month, da;

    while(cin >> month >> da, month)
    {
        string ans;
        switch((day[month - 1] + da) % 7)
        {
            case 0:
                ans = "Wednesday";
                break;
            case 1:
                ans = "Thursday";
                break;
            case 2:
                ans = "Friday";
                break;
            case 3:
                ans = "Saturday";
                break;
            case 4:
                ans = "Sunday";
                break;
            case 5:
                ans = "Monday";
                break;
            case 6:
                ans = "Tuesday";
                break;
        }

        cout << ans << endl;
    }

    return 0;
}