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 <stdio.h>

int main(){
	int m,d;
	int i;
	
	int Days;
	
	
	while(1){
		Days = 0;
		scanf("%d %d",&m,&d);
		if(m == 0&&d == 0)break;
		for(i = 1,Days += d;i < m;i++){
			if(i == 2){
				Days += 29;
			}else if(i == 4||i == 6||i == 9||i == 11){
				Days += 30;
			}else{
				Days += 31;
			}
		}
		
		switch(Days%7){
			case 0:printf("Wednesday\n");
					break;
			case 1:printf("Thursday\n");
					break;
			case 2:printf("Friday\n");
					break;
			case 3:printf("Saturday\n");
					break;
			case 4:printf("Sunday\n");
					break;
			case 5:printf("Monday\n");
					break;
			case 6:printf("Tuesday\n");
					break;
		}
	}
	return 0;
}

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

C++: #include <stdio.h>

int main(void){
  int days[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
  char youbi[7][100] = {"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
  int sum,m,d,i;
  while(1){
    sum = 0;
    scanf("%d %d",&m,&d);
    if (m == 0 || d == 0) break;
    for(i=0;i<m;i++){
      sum += days[i];
    }
    sum += d;
    printf("%s\n",youbi[sum%7]);
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int m,d,h,y;
char w[][7]={"Satur","Sun","Mon","Tues","Wednes","Thurs","Fri"};
for(;;){
y=4;
cin>>m>>d;
if(m==0)break;
if(m<3){m+=12;y--;}
h=(y+int(y/4)+int(2.6*(m+1))+d)%7;
cout<<w[h]<<"day"<<endl;
}
return 0;
}

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

int main()
{
    int mon, day;
    while( cin >> mon >> day )
    {
        int d = 0;
        
        if( mon == 0 && day == 0 )
            break;

        switch( mon )       //入力手前の月の日数分合計し、日にちを足して、最後に7で割った余りを出す。
        {
            case 12:
                d += 30;
            case 11:
                d += 31;
            case 10:
                d += 30;
            case 9:
                d += 31;
            case 8:
                d += 31;
            case 7:
                d += 30;
            case 6:
                d += 31;
            case 5:
                d += 30;
            case 4:
                d += 31;
            case 3:
                d += 29;
            case 2:
                d += 31;
        }

        switch( ( day + 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;
                break;
        }

    }
    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;


int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
char date[7][10] = {"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};


int main(){
    int M,D,days=0;
    
    while(1){
        scanf("%d%d",&M,&D);
        if(M+D==0) break;
    
        for(int i=0;i<M-1;i++)
            days+=month[i];
    
        printf("%s\n",date[(days+D)%7]);
    }
    
    return 0;
}

C++: //#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <math.h>
#include<algorithm>
#include <utility>
using namespace std;
int main() {//Thursda,Friday...0,1,2,3,4,5,6
	int month,day, today;//31%7=3
	int add=0;
	while (1) {
		cin >> month >> today;
		if (month == 0) {
			break;
		}
		if (month == 1) {
			add = 0;
		}
		else {
			for (int i = 1; i < month; i++) {
				if (i == 2) {
					add+=1;
				}
				else if (i % 2 == 0 && i < 8 || i == 11 || i!=12) {
					add += 2;
				}
				else {
					add += 3;
				}
			}
		}
		today += add;
		day = today%7;
		switch (day) {
		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;
		}
		add = 0;
	}
	return 0;
}

C++: #include<stdio.h>
int main(){
	int i,a,b;
	int c[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	int count=0,judge;
	while(1){
		scanf("%d",&a);
		scanf("%d",&b);
		if(a==0&&b==0)
			return 0;
		for(i=0;i<a-1;i++)
			count=count+c[i];
		count= count+b;
		judge=count%7;
		switch(judge){
			case 0:
				printf("Wednesday\n");
				break;
			case 1:
				printf("Thursday\n");
				break;
			case 2:
				printf("Friday\n");
				break;
			case 3:
				printf("Saturday\n");
				break;
			case 4:
				printf("Sunday\n");
				break;
			case 5:
				printf("Monday\n");
				break;
			case 6:
				printf("Tuesday\n");
				break;
		}
	}
	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <math.h>
#include <iterator>
using namespace std;

int main() {
	int c[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };
	while (true) {
		int a, b,d = 0;
		scanf("%d%d", &a, &b);
		if (a == 0) goto end;
		d = b;
		for (int i = 0;i < a-1;++i) {
			d += c[i];
		}
		if (d%7 == 6) {
			printf("Tuesday\n");
		}
		else if (d % 7 == 0) {
			printf("Wednesday\n");
		}
		else if (d % 7 == 1) {
			printf("Thursday\n");
		}
		else if (d % 7 == 2) {
			printf("Friday\n");
		}
		else if (d % 7 == 3) {
			printf("Saturday\n");
		}
		else if (d % 7 == 4) {
			printf("Sunday\n");
		}
		else if (d % 7 == 5) {
			printf("Monday\n");
		}
	}
end:;
}

C++: //0027 What day is today?

//2004N11ú`1231úÜÅÌútðüÍµ½Æ«A»Ìjúð¦Ä­¾³¢
//È¨2004N11úÍØjúÅA2004NÍ[NÅ·

#include<iostream>
#include<numeric>
using namespace std;

int main(void)
{
	const char* week[] = 
	{
		"Monday",
		"Tuesday",
		"Wednesday",
		"Thursday",
		"Friday",
		"Saturday",
		"Sunday",
	};
	//indexÌú
	const int days[13] = 
	{
		0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
	};
	//indexÌ1úÌA11ú©çÌoßú
	int elapsedDays[13];
	partial_sum(days, days+13, elapsedDays);

	int month, day;
	
	while(cin >> month >> day, month)
	{
		cout << week[ (elapsedDays[month-1] + day + 2) %  7] << endl;
	}
	return 0;
}