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 <cstdio>
#include <iostream>

using namespace std;

int main(){
	int days[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
	//char week1[7][10] = {"??¨?????\","????????\","????????\","??\?????\","????????\","????????\","?°´?????\"};
	char week2[7][10] = {"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};

	int month,day;
	int sum;

	while((cin >> month) != 0 && (cin >>day) != 0){
		sum = 0;
		for(int i=0 ;i < month - 1;i++){
			sum += days[i];
		}
		sum += day;

		switch(sum % 7){
			case 1:
				printf("%s\n",week2[0]);
				break;

			case 2:
				printf("%s\n",week2[1]);
				break;

			case 3:
				printf("%s\n",week2[2]);
				break;

			case 4:
				printf("%s\n",week2[3]);
				break;

			case 5:
				printf("%s\n",week2[4]);
				break;

			case 6:
				printf("%s\n",week2[5]);
				break;

			case 0:
				printf("%s\n",week2[6]);
				break;

		}


	}
}

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","Tuseday"};
    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>
using namespace std;
int main(){
	int m,d;
	while(cin>>m>>d){
		if(!m) break;
		int daym[12]={0,31,60,91,121,152,182,213,244,274,305,335};
		int wd = (daym[m-1] + d + 2)%7;
		switch(wd){
		case 0:
			cout <<"Monday"<<endl;
			break;
		case 1:
			cout<<"Tuesday"<<endl;
			break;
		case 2:
			cout<<"Wednesday"<<endl;
			break;
		case 3:
			cout<<"Thursday"<<endl;
			break;
		case 4:
			cout<<"Friday"<<endl;
			break;
		case 5:
			cout<<"Saturday"<<endl;
			break;
		case 6:
			cout<<"Sunday"<<endl;
			break;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,n) for(long long int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long ll;
typedef vector<long long int> vi;
typedef vector<long long int>::iterator vit;

int main(){
	int m, d, c;
	while (cin >> m >> d){
		if (m == 0)break;
		if (m == 1||m==9||m==12)c = 0;
		else if (m ==4||m==7)c = 1;
		else if (m == 10)c = 2;
		else if (m == 2 || m == 5)c = 3;
		else if (m == 8)c = 4;
		else if (m == 11)c = 5;
		else c = 6;
		c = (c + d) % 7;
		if (c == 1){
			cout << "Thursday\n";
		}
		else if (c == 2){
			cout << "Friday\n";
		}
		else if (c == 3){
			cout << "Saturday\n";
		}
		else if (c == 4){
			cout << "Sunday\n";
		}
		else if (c == 5){
			cout << "Monday\n";
		}
		else if (c == 6){
			cout << "Tuesday\n";
		}
		else {
			cout << "Wednesday\n";
		}
	}

}

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

int main(){
	int m[13], mm, dd, i;
	m[0] = 0;
	m[1] = m[0];
	m[2] = m[1] + 31;
	m[3] = m[2] + 29;
	m[4] = m[3] + 31;
	m[5] = m[4] + 30;
	m[6] = m[5] + 31;
	m[7] = m[6] + 30;
	m[8] = m[7] + 31;
	m[9] = m[8] + 31;
	m[10] = m[9] + 30;
	m[11] = m[10] + 31;
	m[12] = m[11] + 30;

	string day[7];
	day[0] = "Wednesday";
	day[1] = "Thursday";
	day[2] = "Friday";
	day[3] = "Saturday";
	day[4] = "Sunday";
	day[5] = "Monday";
	day[6] = "Tuesday";

	while (true)
	{
		cin >> mm >> dd;
		if (mm == 0) { break; }
		i = (m[mm] + dd) % 7;
		cout << day[i] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
const int year = 2004;

string getDay(int mm, int dd)
{
    int yy = year;
    int ans;
    if(mm <= 2)
    {
        yy -= 1;
        mm += 12;
    }
    ans = (
        dd + ((8+(13 * mm))/5)
        + (yy + (yy / 4) - (yy / 100))
        + (yy / 400)
    ) % 7;

    switch(ans)
    {
        case 0:
            return "Sunday";
        case 1:
            return "Monday";
        case 2:
            return "Tuesday";
        case 3:
            return "Wednesday";
        case 4:
            return "Thursday";
        case 5:
            return "Friday";
        case 6:
            return "Saturday";
    }
}

int main()
{
    int mm, dd;
    while(1)
    {
        cin >> mm >> dd;
        if(mm == 0) break;
        cout << getDay(mm, dd) << endl;
    }

    return EXIT_SUCCESS;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int monthNum[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	string dayName[7] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};
	int month, day, passDay=0;
	
	while (1) {
		cin >> month; cin >> day;
		if (month == 0) break;
		
		for (int i=0; i<month; i++)
			passDay += monthNum[i];
		passDay += day-1;
		
		cout << dayName[passDay % 7] << endl;
	}
	
	return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
    for(;;){
	int m,d;
	int data[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	cin>>m>>d;
	if(m==0&&d==0)break;
	for(int i=1;i<=m;i++){
        d+=data[i-1];
	}
	switch(d%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;
    }




    }




	return 0;
}

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

int main()
{
	int month,day;
	int months[] = {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 <iostream>
#include <string>
using namespace std;

int main() {
  int days[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
  string youbi[7] = {"Monsay","Tuesday","Wednesday","Thursday",
		     "Friday","Saturday","Sunday"};
  while(1) {
    int mon, day;
    cin >> mon >> day;
    if(mon == 0) break;

    int sum = 0;
    for(int i = 0; i < mon-1; i++) {
      sum += days[i];
    }
    sum += day;

    cout << youbi[(sum+2)%7] << endl;
  }
  return 0;
}

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