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>
#include <cstdio>
using namespace std;
int main(){
	int m,d;
	int day[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
	int y[12];
	string s[7] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	y[0] = 3;
	for(int i=1;i<12;i++) y[i] = (y[i-1]+day[i-1])%7;
	while(1){
		cin >> m >> d;
		if(m==0) break;
		int t = (y[m-1]+d-1)%7;
		cout << s[t] << 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] = {"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%7+2] << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main()
{
	int day[] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	for (int i = 1; i < 12; i++) {
		day[i] += day[i - 1];
	}
	int mo, da;
	while (cin >> mo >> da, mo | da) {
		switch ((day[mo - 1] + da - 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;
		default:
			break;
		}
	}
	return 0;
}

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

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;


int zeller(int y , int m , int d){
	if(m==1 || m==2) {m+=12; y-=1;}
	return(y + y/4 - y/100 + y/400 + ((13*m+8)/5) + d )%7;
}

int main(){
	int m , d , w=4 , fw;
	while (cin >> m >> d, m){
		switch(zeller(2004,m,d)){
			case 0:
			cout << "Sunday" << endl;
			break;
			case 1:
			cout << "Monday" << endl;
			break;
			case 2:
			cout << "Tuesday" << endl;
			break;
			case 3:
			cout << "Wednesday" << endl;
			break;
			case 4:
			cout << "Thursday" << endl;
			break;
			case 5:
			cout << "Friday" << endl;
			break;
			case 6:
			cout << "Saturday" << endl;
		}
	}
	return 0; 
}

C++: #include <stdio.h>

int total[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30};

int Sum(int x) {
  int i, sum = 0;
  for(i = 0; i < x; i ++) {
    sum += total[i];
  }

  return sum;
}

int main() {
  int month, day;
  while(scanf("%d %d", &month, &day)) {
    if(month == 0) break;

    switch((Sum(month - 1) + day)%7) {
      case 0:
        printf("Thursday\n");
        break;

      case 1:
        printf("Friday\n");
        break;

      case 2:
        printf("Saturday\n");
        break;

      case 3:
        printf("Sunday\n");
        break;

C++: #include <stdio.h>
int main(){
	char day[][16] = {"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
	int month[12] = {30,28,30,29,30,29,30,30,29,30,29,30};
	int m,d,i,n;
	while(1){
		n=0;
		scanf("%d%d",&m,&d);
		if(!m&&!d) break;
		for(i=0;i<m-1;i++) n += month[i]+1;
		n+=d-1;
		n = n%7;
		printf("%s\n",day[n]);
	}
	return 0;
}

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

int main(){
  int m,d;
  int cnt;
  string days[8]={"\0","Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
  while(1){
    cnt = 0;
    cin >> m >> d;
    if(m == 0 && d == 0) break;
    cnt += d;
    for(m--;m>0;m--){
      switch (m){
      case 4:
      case 6:
      case 9:
      case 11:
	cnt += 30;
      case 2:
	cnt += 29;
      default:
	cnt += 31;
      }
    }
    cout << days[cnt%7] << endl;
  }
}

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

int main() {
	int m,d;
	cin >> m >> d;
	
	while(m!=0 && d!=0){
		int days=0;
		days+=d;
		
		if(m==2)days+=31;
		else if(m==3)days+=60;
		else if(m==4)days+=91;
		else if(m==5)days+=121;
		else if(m==6)days+=152;
		else if(m==7)days+=182;
		else if(m==8)days+=213;
		else if(m==9)days+=244;
		else if(m==10)days+=274;
		else if(m==11)days+=305;
		else if(m==12)days+=335;
		
		days %= 7;
		
		switch(days){
		case 1: cout << "Thursday";break;
		case 2: cout << "Friday" ;break;
		case 3: cout << "Saturday";break;
		case 4: cout << "Sunday";break;
		case 5: cout<<"Monday";break;
		case 6: cout <<"Tuesday";break;
		case 0: cout <<"Wednesday";break;
		
		}
		cout << endl;
		
		cin >> m >> d;
	}
	return 0;
}

C++: #define ll    long long
#define pb    push_back
#define mk    make_pair
#define f     first
#define s     second
#define pii   pair<int, int>
#define fuck  return 0;

#include<bits/stdc++.h>
using namespace std;


int main()
{
   string a[7]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"} ;
   int sum = 0, day[12]={31,29,31,30,31,30,31,31,30,31,30,31};

   int m, d;

   while((cin >>m >>d) && (m!=0 && d!=0))
   {
       for(int i=0; i<=m-2; i++) sum+= day[i];


       sum += d;
       int ans = sum % 7;
       cout <<a[ans] << endl;
     sum=0;
   }
}

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

#define YEAR 2004

using namespace std;

int main() {
	vector<string> week;
	week.push_back("Monday");
	week.push_back("Tuesday");
	week.push_back("Wednesday");
	week.push_back("Thursday");
	week.push_back("Friday");
	week.push_back("Saturday");
	week.push_back("Sunday");
	int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};

	int m,d;
	int index = 3; //1月1日が木曜日なので

	while(cin>>m>>d){
		if(m==0 || d==0){ break; }
		for(int i=0; i<m; i++){
			for(int j=1; j<=month[i]; j++){
				if(i+1==m and j==d){ break; }
				index++;
				if(index == 7) index=0;
			}
		}
		cout<<week[index]<<endl;
		index = 3;
	}
	return 0;
}

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

using namespace std;

int min(){
	string y[7] = {"Wednesday", "Thrsday", "Frinday", "Saturday", "Sunday", "Monday", "Tuesday"};
	int mon[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

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

		while(m != 0){
			d = d + mon[m-1];
		}
		cout << y[d%7] << endl;
	}
}

C++: 
      case 6:
        printf("Tuesday\n");
        break;
    }
  }

  return 0;
}