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 a, b, count = 0;
	int ans[100];
	while (cin >> a >> b) {
		if (a == 0)
			break;
		if (a == 1 || a == 4 || a == 7) {
			ans[count] = (b % 7 + 3)%7;
			if (ans[count] % 7 == 0)
				ans[count] = +7;
		}
		else if (a == 9 || a == 12) {
			ans[count] = (b % 7 + 2)%7;
			if (ans[count] % 7 == 0)
				ans[count] = +7;
		}
		else if (a == 2 || a == 8) {
			ans[count] = (b % 7 + 6)%7;
			if (ans[count] % 7 == 0)
				ans[count] = +7;
		}
		else if (a == 3 || a == 11) {
			ans[count] = b % 7;
			if (ans[count] % 7 == 0)
				ans[count]=+7;
		}
		else if (a == 5) {
			ans[count] = (b % 7 + 5)%7;
			if (ans[count] % 7 == 0)
				ans[count] = +7;
		}
		else if (a == 6) {
			ans[count] = (b % 7 + 1)%7;
			if (ans[count] % 7 == 0)
				ans[count] = +7;
		}
		else if (a == 10) {
			ans[count] = (b % 7 + 4)%7;
			if (ans[count] % 7 == 0)
				ans[count] = +7;
		}
		count++;
	}
	for (int i = 0; i < count; i++) {
		if (ans[i] == 1)
			cout << "Monday" << endl;
		else if (ans[i] == 2)
			cout << "Tuesday" << endl;
		else if (ans[i] == 3)
			cout << "Wednesday" << endl;
		else if (ans[i] == 4)
			cout << "Thursday" << endl;
		else if (ans[i] == 5)
			cout << "Friday" << endl;
		else if (ans[i] == 6)
			cout << "Saturday" << endl;
		else if (ans[i] == 7)
			cout << "Sunday" << endl;
	}
}

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

int main(){
  int m,d,x,i;

  while(1){
    cin>>m>>d;
    if(m==0&&d==0)break;
    x=0;
    for(i=1;i<m;i++){
      switch(i){
      case 1:
      case 3:
      case 5:
      case 7:
      case 8:
      case 10:
      case 12:
	x+=3;
	break;      
      case 2:
	x+=1;
	break;
      default:
	x+=2;
      }
    }
  switch((x+d-1)%7){
      case 0:
	cout<<"Thursday"<<endl;
	break;

      case 1:
	cout<<"Friday"<<endl;
	break;

      case 2:
	cout<<"Saturday"<<endl;
	break;

      case 3:
	cout<<"Sunday"<<endl;
	break;

      case 4:
	cout<<"Monday"<<endl;
	break;

      case 5:
	cout<<"Tuesday"<<endl;
	break;

      case 6:
	cout<<"Wednesday"<<endl;
	break;
  }
  }  
  return 0;
}

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

using namespace std;

int main()
{
    int m, d;
    string day[] = {"Sunday", "Monday", 
                    "Tuesday", "Wednesday", "Thursday",
                    "Friday", "Saturday"};

    while (cin >> m >> d) {
        if (!m && !d)
            break;

        int year = 2004, h;
        if (m == 1 || m == 2) {
            year--;
            m += 12;
        }
        h = (year + year / 4 - year / 100 + year / 400 + (13 * m + 8) / 5 + d) % 7;
        
        cout << day[h] << endl;
    }

    return 0;
}

C++: #include<cstdio>

int day_date[12]={3,6,0,3,5,1,3,6,2,4,0,2};
int mon;
int day;

int main()
{
	while(true)
	{
		scanf("%d%d",&mon,&day);
		if(mon==0)break;
		int date=(day+day_date[mon-1]-1)%7;
		if(date==0) printf("Monday");
		if(date==1) printf("Tuesday");
		if(date==2) printf("Wednesday");
		if(date==3) printf("Thursday");
		if(date==4) printf("Friday");
		if(date==5) printf("Saturday");
		if(date==6) printf("Sunday");
		printf("\n");
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int a[13][32];
void day(void)
{
    int check=3;
    for(int i=1;i<13;i++){
        for(int j=1;j<32;j++){
            a[i][j]=check;
            check++;
            if(check==7)check=0;
            if((i==4||i==6||i==9||i==11)&&j==30)break;
            else if(i==2&&j==29)break;
        }
    }
}
int main()
{
    int mon,date;
    day();
    while(1){
        cin>>mon>>date;
        if(mon==0&&date==0)break;
        if(a[mon][date]==0)cout<<"Monday\n";
        else if(a[mon][date]==1)cout<<"Tuesday\n";
        else if(a[mon][date]==2)cout<<"Wednesday\n";
        else if(a[mon][date]==3)cout<<"Thrusday\n";
        else if(a[mon][date]==4)cout<<"Friday\n";
        else if(a[mon][date]==5)cout<<"Saturday\n";
        else cout<<"Sunday\n";
    }

}

C++: //1=31,2=29,3=31,4=30,5=31,6=30,7=31,8=31,9=30,10=31,11=30,12=31//
#include <iostream>
#include<string>
using namespace std;
int main(){
    string str[7]{"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
    int t[11]{31,60,91,121,152,182,213,244,274,305,335};
    //        0   1  2  3   4   5   6  7    8   9   10//
    int d,m;
    while(cin>>m>>d){
        if(m==0)break;
        if(m==1)cout<<str[d%7]<<endl;
        else{
            d=d+t[m-2];
            cout<<str[d%7]<<endl;
        }
    }
    return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int data[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	string out[7]={
	"Wednesday",
	"Thursday",
	"Friday",
	"Saturday",
	"Sunday",
	"Monday",
	"Tuesday"
	};
	int a,b;
	while(cin>>a>>b,a+b){
		int sum=b;
		rep(i,a-1)sum+=data[i];
		cout<<out[sum%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 304+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>
using namespace std;
int main(void)
{
  int m, d;
  
  while(1) {
    cin >> m >> d;
    if(m == 0) break;
    
    for(int i = m ; i > 1 ; i--) {
      if(i-1 == 4 || i-1 == 6 || i-1 == 9 || i-1 == 11) d += 30;
      else if(i-1 == 2) d += 29;
      else if(i-1 == 1 || i-1 == 3 || i-1 == 5 || i-1 == 7 || i-1 == 8 || i-1 == 10) d += 31;
    }
    
    if(d % 7 == 1) cout << "Thursday" << endl;
    if(d % 7 == 2) cout << "Friday" << endl;
    if(d % 7 == 3) cout << "Saturday" << endl;
    if(d % 7 == 4) cout << "Sunday" << endl;
    if(d % 7 == 5) cout << "Monday" << endl;
    if(d % 7 == 6) cout << "Tuesday" << endl;
    if(d % 7 == 0) cout << "Wednesday" << endl;
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int m,d;
	while(cin >> m >> d,m){
		int sum = 0;
		for(int i = 1; i < m; i++){
			switch(i){
				case 1:
				case 3:
				case 5:
				case 7:
				case 8:
				case 10:
					sum += 31;
					break;
				case 4:
				case 6:
				case 9:
				case 11:
					sum += 30;
					break;
				case 2:
					sum += 29;
					break;
				default:
					break;
			}
		}
		sum += d;
		switch(sum%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;
}