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 <algorithm>
#include <string>
#include <cmath>
#include <stack>
using namespace std;

int main(){
	int m,d;
	while(cin >> m >> d){
		if(m == 0 && d == 0)break;
		int n = 0;
		for(int i = 1; i < m; i++){
			if(i == 2)n += 29;
			else if(i == 4 || i == 6 || i == 9 || i == 11)n += 30;
			else n += 31;
		}
		n += d;
		switch(n % 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 main()
{
	int monthday[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	const char *weekday[7] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};
	
	int month, day;
	
	while(cin >> month >> day, month)
	{
		if(month == 0) break;
		
		int w = day - 1;
		for(int i = 1; i < month; i++)
		    w += monthday[i];
		cout << weekday[w % 7] << endl;
	}
	return 0;
}

C++: #include <iostream>

using std::cout;
using std::endl;

int getDays(int month, int day);

int main()
{
    int month, day;
    while (true) {
        std::cin >> month >> day;

        if (month == 0 && day == 0) {
            break;
        }

        int days = getDays(month, day);
        int mod = days % 7;
        switch (mod) {
        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;
        }
    }

    return 0;
}

int getDays(int month, int day)
{
    int days = 31 * (month - 1) + day;

    int minus = 0;
    if (month > 2) {
        minus += 2;
    }
    if (month > 4) {
        minus++;
    }
    if (month > 6) {
        minus++;
    }
    if (month > 9) {
        minus++;
    }
    if (month > 11) {
        minus++;
    }

    return (days -= minus);
}

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

using namespace std;

int main(){
	string y[7] = {"Wednesday", "Thrsday", "Frinday", "Saturday", "Sunday", "Monday", "Tuesday"};
	int mon[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

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

		while(m != 0){
			d = d + mon[m-1];
			m--;
		}
		cout << y[d%7] << endl;
	}
return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
int main() {
	int m, d;
	int dd[13] = { 0,31,29,31,30,31,30,31,31,30,31,30,31 };
	string Mon[7] = { "Monday","Tuesday" , "Wednesday" , "Thursday" , "Friday", "Saturday", "Sunday" };
	while (cin >> m >> d) {
		int day = 2;
		if (m == 0 && d == 0) break;
		for (int i = 1; i < m;i++) {
			day += dd[i];
		}
		day += d;
		day %= 7;
		cout << Mon[day] << endl;
	}
}

C++: #include <iostream>
using namespace std;
int main(){
  int m,d,s[]={0,31,29,31,30,31,30,31,31,30,31,30};
  string day[]={"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
  for(;cin>>m>>d,m||d;)
    {
      d--;
      for(int i=0;i<m;i++)
	d+=s[i];
      cout<<day[d%7]<<endl;
    }
  return 0;
}

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

int getDay(int y,int m,int d){
	if(m<3) m += 12 , y--;
	int J = y/100 , K = y%100;
	return (d + (((m+1)*26)/10) + K + (K/4) + (J/4) + 5*J) % 7;
}
int main(){
	string table[] = {"Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"};
	int m,d;
	while(cin >> m >> d , m){
		cout << table[getDay(2004,m,d)] << endl;
	}
}

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

int main()
{
    string day[]={"Wednesday","Thirsday","Friday","Saturday","Sunday","Monday","Tuesday"};
    int Mon[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
    int m,d;
    while(cin>>m>>d,m){
        int allDay=d;
        for(;m>0;m--){
            allDay += Mon[m-1];
        }
        cout<<day[allDay%7]<<endl;
    }
}

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

int main(){
   int month=1,daily=1,day[13] ={0,31,29,31,30,31,30,31,31,30,31,30,31},date = 0;
   while(1){
    int poi;
    poi = 0;
    cin >> month >> daily;
    if(month == 0) break;
    for(int i = 1;i < month;++i){
       poi += day[i];
    }
    date = (poi + daily + 3) % 7;
    if(date == 0) cout << "Sunday" << endl;
    if(date == 1) cout << "Monday" << endl;
    if(date == 2) cout << "Tuesday" << endl;
    if(date == 3) cout << "Wednesday" << endl;
    if(date == 4) cout << "Thursday" << endl;
    if(date == 5) cout << "Friday" << endl;
    if(date == 6) cout << "Saturday" << endl;
  }
 return 0;
}

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 && d == 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;

int main() {

  int data[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int month, day;
  while( cin >> month >> day, month + day ) {
    int sum = 0;
    for(int i=0; i<month-1; i++) {
      sum += data[i];
    }
    sum += day;
    sum %= 7;

    if( sum == 1 ) {
      cout << "Thursday" << endl;
    }
    else if( sum == 2 ) {
      cout << "Friday" << endl;
    }
    else if( sum == 3 ) {
      cout << "Saturday" << endl;
    }
    else if( sum == 4 ) {
      cout << "Sunday" << endl;
    }
    else if( sum == 5 ) {
      cout << "Monday" << endl;
    }
    else if( sum == 6 ) {
      cout << "Tuesday" << endl;
    }
    else if( sum == 0 ) {
      cout << "Wednesday" << endl;
    }
  }
}

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

int main()
{
	int days[13] = { 0,31,29,31,30,31,30,31,31,30,31,30,31};
	string ans[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

int month, date;

	//前月までの延べ日数に変換
	for( int i = 1; i < 13; i++ ) {
		days[i] += days[i-1];
	}

	while( 1) {
		cin >> month >> date;
		if( month == 0 )
			return -1;
		
		int day = days[month-1] + date + 3;
		int p = day %7;

		cout << ans[p] << endl;

	}
	return 0;
}

C++: #include <stdio.h>

int main()
{
  int y, d, m;
  int h;
  char *date[] = {"Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"};

  for(;;)
    {
      int Y, C, G;
      y = 2004;

      scanf("%d %d", &m, &d);

      if(d == 0 || m == 0) break;
      if(m == 1 || m == 2)
	{
	  m += 12;
	  y--;
	}

      Y = y%100;
      C = y/100;
      G = (-2*C) + (C/4);

      h = (d + (26*(m + 1)/10) + Y + Y/4 + G)%7;

      printf("%s\n", date[h]);
    }

  return 0;
}