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(){
	int m,d,n=0,date[50]={0},i=0;
	while(cin>>m&&m!=0){
		cin>>d;
		switch(m){
			case 1:
				break;
			case 2:
				d=d+3;
				break;
			case 3:
				d=d+4;
				break;
			case 4:
				d=d+3;
				break;
			case 5:
				d=d+6;
				break;
			case 6:
				d=d+1;
				break;
			case 7:
				d=d+4;
				break;
			case 8:
				break;
			case 9:
				d=d+2;
				break;
			case 10:
				d=d+5;
				break;
			case 11:
				break;
			case 12:
				d=d+3;
				break;
		}
		date[i]=d%7;
		cout<<date[i]<<endl;
		i++;
		n++;
	}
	for(int i=0;i<n;i++){
		switch(date[i]){
			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 day30[5] = {3,4,6,9,11};

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

  while(1) {

    if(a == m && b == d) break;
    
    b++;
    count++;

    if(a == 2 && b == 30) {
      a++;
      b = 1;
    }
    else if(b == 31) {
      for(int i=0;i<5;i++) 
	if(day30[i] == a) {
	  a++;
	  b = 1;
	  break;
	}
    }
    if( b == 32) {
      a++;
      b = 1;
    }
  }
  
  if(count % 7 == 4 ) cout <<"Monday"<<endl;
  else if(count % 7 == 5) cout << "Tuesday"<<endl;
  else if(count % 7 == 6) cout <<"Wednesday"<< endl;
  else if(count % 7 == 0) cout <<"Thursday"<< endl;
  else if(count % 7 ==1) cout << "Friday" << endl;
  else if(count % 7 ==2)cout << "Saturday" << endl;
  else if(count % 7 ==3) cout << "Sunday" << endl;
  
  }

  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <queue>
#include <stack>
#include <utility>
#include <queue>
#include <cmath>
#define mp make_pair
#define pii pair<int,int> 
#define ff first
#define ss second

using namespace std;

int month[20]={0,31,29,31,30,31,30,31,31,30,31,30,31};
string days[10]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
int a,b,c;
int main()
{
	while(1)
	{
		scanf("%d %d",&a,&b);
		c=0;
		if(a==0&&b==0)
		{
			break;
		}
		for(int i=1;i<a;i++)
		{
			c+=month[i];
		}
		c+=b;
		c%=7;
		printf("%d\n",c);
		cout<<days[c]<<endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD


int days[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
string week[7] = {"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
int main(){
  while(true){
    int m,d;
    cin>>m>>d;
    if(m==0 && d==0)break;
    --m;
    int day = 0;
    REP(i,m) day += days[i];
    day += d;
    day %= 7;
    cout<<week[day]<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	string week[7] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
	int m,d,count_w, count_m;
	while(cin >> m >> d){
		if(m == 0) return 0;
		
		count_m = 1;
		count_w = 3;
		while(m != count_m){
			for(int i=1; i<=month[count_m-1]; i++, count_w++)
				if(m==count_m && d==i) break;
			count_m++;
		}
		cout << week[count_w%7] << endl;
	}
}

C++: #include <iostream>

int main(){
	using namespace std;
	while(1){
	int month,day,year = 2004,mod;
	cin >> month >> day;
	if (month==0) break;
	else if (month<=2) {
		month += 12;
		year -= 1;
	}
	int k = year % 100;
	int j = year / 100;
	mod = (day+(((month+1)*26)/10)+k+(k/4)+(j/4)+5*j)%7;
	if (mod == 0) cout << "Saturday" << endl;
	else if (mod == 1) cout << "Sunday" << endl;
	else if (mod == 2) cout << "Monday" << endl;
	else if (mod == 3) cout << "Tuesday" << endl;
	else if (mod == 4) cout << "Wednesday" << endl;
	else if (mod == 5) cout << "Thursday" << endl;
	else if (mod == 6) cout << "Friday" << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main( void )
{
	int days[13] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	string d[7] = { "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday" };

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

		for ( int i = 1; i < month; i++ )
		{
			day += days[i];
		}

		day--;
		int index = day % 7;
		cout << d[index] << endl;

	}

	return 0;
}

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

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 main()
{

int month, date;

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

	while( 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<iostream>
using namespace std;

int main(void){

    string day[7] = {"Monday","tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
    int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
    int x,y;

    while(cin >> x >> y){
        if(x == 0 || y == 0){
            break;
        }


        for(int i = 0;i < x-1;i++){
            y += month[i];
        }

        cout << day[(y%7+2)%7] << endl;


        




    }


    return 0;
}

C++: #include <iostream>

using namespace std;
int MONTH[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
char day_of_the_week[32][32] = {{"Thursday"},
								{"Friday"},
								{"Saturday"},
								{"Sunday"},
								{"Monday"},
								{"Tuesday"},
								{"Wednesday"},
};
void solve()
{
	int month, day;
	while(cin >> month >> day, month || day)
	{
		int sum = 0;
		for(int i = 0; i < month - 1; ++i)
		{
			sum += MONTH[i];
		}
		sum += day - 1;
		cout << day_of_the_week[sum % 7] << endl;
	}
}

int main()
{
	solve();
	return(0);
}