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 <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
using namespace std;

int main(){
	int m,n,end[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	while(1){
		int day=0,r;
		cin>>m>>n;
		if(m==0) break;
		rep(i,0,m-1) day+=end[i];
		day+=n;
		r=day%7;
		if(r==1) cout<<"Thursday"<<endl;
		else if(r==2) cout<<"Friday"<<endl;
		else if(r==3) cout<<"Saturday"<<endl;
		else if(r==4) cout<<"Sunday"<<endl;
		else if(r==5) cout<<"Monday"<<endl;
		else if(r==6) cout<<"Tuesday"<<endl;
		else if(r==0) cout<<"Wednesday"<<endl;
	}
}

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

int main() {
  int month, date;
  int day[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  const char *label[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
  int day_sum[12];
  int x;

  day_sum[0] = 0;
  for (int i=1; i<12; i++) {
    day_sum[i] = day_sum[i-1] + day[i-1];
  }

  while (1) {
    cin >> month >> date;
    if (!month && !date) break;
    x = day_sum[month-1] + date + 2;
    cout << label[x%7] << endl;
  }

  return 0;
}

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:
				break;
			case 5:
				d=d+3;
				break;
			case 6:
				d=d+5;
				break;
			case 7:
				break;
			case 8:
				d=d+3;
				break;
			case 9:
				d=d+6;
				break;
			case 10:
				d=d+1;
				break;
			case 11:
				d=d+4;
				break;
			case 12:
				d=d+6;
				break;
		}
		date[i]=d%7;
		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;

const char *weeks[]={"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
const int days[]={0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(true){
        int month, day;
        cin>>month>>day;
        if(month==0) break;
        int week=3;
        for(int i=1; i<month; i++) week=(week+days[i])%7;
        week=(week+day)%7;
        cout<<weeks[week]<<'\n';
    }
    return 0;
}

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

using namespace std;

//0027
int main(){
	int days[] = {31,29,31,30,31,30,31,31,30,31,30,31};
	string week[7] = {"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
	int m, d;
	while(cin >> m >> d, m||d){
		int ans = 0;
		for(int i=1; i<m; ++i){
			ans += days[i-1];
		}
		ans += d;

		ans = ans % 7;
		cout << week[ans] <<endl;

	}
}

C++: #include<iostream>
#include<string>
#include<memory.h>
using namespace std;
int main()
{
	//2004-1-1 Tuesday
	int a[370];
	string youbi[7] = {
		 "Monday", "Tuesday","Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
	int m[13] = { 0,0, 31,60 ,91,121, 152, 182,213 , 244, 274, 305, 335 };
	for (int i = 3; i <= 365+3; i++){
		a[i] = i % 7;
	}
	while (true){
		int x, y;
		cin >> x >> y;
		if (x == 0 && y == 0)break;
		cout << youbi[a[m[x] + y + 2]] << endl;
	}
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

int dayofweek(int year, int month, int day)
{
	struct tm  t;

	t.tm_year = year - 1900;    /* ??´????????´ */
	t.tm_mon = month - 1;        /* ???????????´ */
	t.tm_mday = day;            /* ??\ */
	t.tm_hour = 0;                /* ??? */
	t.tm_min = 0;                /* ??? */
	t.tm_sec = 0;                /* ?§? */
	t.tm_isdst = -1;            /* ????????? */

	if (mktime(&t) == -1)        /* ???????????±??? */
		return (-1);
	return (t.tm_wday);
}

int main() {
	map<int, string>m;
	m[0] = "Sunday";
	m[1] = "Monday";
	m[2] = "Tuesday";
	m[3] = "Wednesday";
	m[4] = "Thursday";
	m[5] = "Friday";
	m[6] = "Saturday";
	while (1) {
		int a, b; cin >> a >> b;
		if (!a)break;
		int num = dayofweek(2004, a, b);
		cout << m[num] << endl;
	}
	return 0;
}

C++: #include <cstdio>

using namespace std;

bool testcase_ends() {
    int m, d;
    scanf("%d %d", &m, &d);

    if (m == 0 && d == 0)
        return 1;

    int offset[]={
        0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335
    };

    const char *day[]={
        "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur", "Sun"
    };

    printf("%sday\n", day[(offset[m-1]+d+2)%7]);
    return 0;
}

int main() {
    int solved=0;
    while (!testcase_ends())
        ++solved;

    return !solved;
}

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

int main()
{
	int month[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
	int m,d;
	while(cin >> m >> d){
		if(m==0&&d==0)
			break;
		int day=0;
		for(int i=1;i<m;i++){
			day+=month[i];
		}
		day+=d;
		switch(day%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;
			default:
				break;
		}
	}
	return 0;
}

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

double r(double x1,double y1,double x2,double y2){
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	
	}

int main() {
	// your code goes here
int a[13];
a[1]=31;
a[2]=29;
a[3]=31;
a[4]=30;
a[5]=31;
a[6]=30;
a[7]=31;
a[8]=31;
a[9]=30;
a[10]=31;
a[11]=30;
a[12]=31;

int m,d,z,y;
cin>>m>>d;
while(m!=0){
	if(m==0) z=d;
	else{
		z=d;
		for(int i=1;i<m;i++){
			z=z+a[i];
		}
	}
	y=z%7;
	if(y==1){
		cout<<"Thursday"<<endl;
	}
		if(y==2){
		cout<<"Friday"<<endl;
	}
		if(y==3){
		cout<<"Saturday"<<endl;
	}
		if(y==4){
		cout<<"Sunday"<<endl;
	}
		if(y==5){
		cout<<"Monday"<<endl;
	}
		if(y==6){
		cout<<"Tuesday"<<endl;
	}
		if(y==0){
		cout<<"Wednesday"<<endl;
	}

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] = {"Monday","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;
}