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 <string>
using namespace std;
 
int main(){
  string y[7]={"Wednesday","Thursday","Friday","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 && d == 0 ) break;
    while( m != 0 ){
      d += mon[m-1];
      m--;
    }
    cout << y[d%7] << endl;
  }
 
  return 0;
}

C++: #include<iostream>
int main()
{
	while (true)
	{
		int passed = 0;
		int days[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };
		int m, d;
		std::cin >> m >> d;
		if (m == 0)
		{
			break;
		}
		for (int i = 0; i < m - 1; i++)
		{
			passed += days[i];
		}
		passed += d - 1;
		switch (passed % 7)
		{
		case 0:
			std::cout << "Thursday" << std::endl;
			break;
		case 1:
			std::cout << "Friday" << std::endl;
			break;
		case 2:
			std::cout << "Saturday" << std::endl;
			break;
		case 3:
			std::cout << "Sunday" << std::endl;
			break;
		case 4:
			std::cout << "Monday" << std::endl;
			break;
		case 5:
			std::cout << "Tuesday" << std::endl;
			break;
		case 6:
			std::cout << "Wednesday" << std::endl;
			break;
		}
	}
	return 0;
}

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

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

int main(void){

    string day[7] = {"Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"};
    //int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
    int x,y;

    while(cin >> x >> y){
        int h = 20;
        int n = 4;
        if(x == 0){
            return 0;
        }
        if(x == 1 || x == 2){
            n--;
            x+=12;
        }
                       
        int w = n + n/4 + h/4 - 2*h + 13*(x+1)/5 + y;
        //cout << w << endl;
       
        //cout << w%7 << endl;

        string ans = day[w%7];

        cout << ans << endl;
    }
    return 0;
}

C++: #include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define F first
#define S second
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl

string yobi[7]={
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday"
};

int main(){
	li m,d;
	li acum=3;
	li day[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	
	while(1){
		cin>>m>>d;
		if(min(m,d)==0)break;
		
		rep(i,m-1)acum+=day[i];
		acum+=d-1;
		cout<<yobi[acum%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,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 << s[o%7] << endl;cin>>a>>b;
  }
}

C++: //https://onlinejudge.u-aizu.ac.jp/problems/0027

#include <bits/stdc++.h>

using namespace std;

string day[7] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};
int months[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
    int m, d;

    while (true) {
        cin >> m >> d;
        if (m + d == 0) return 0;

        m--;
        d--;
        for (int i = 0; i < m; ++i) {
            d += months[i];
        }
        cout << day[d % 7] << endl;
    }
}

/*
 * 1/1から何日ずれるか数えて7で割る。
 */

C++: #include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    int a, b;
    string date[7] = { "Wednesday", "Thursday", "Friday", "Saturday",
        "Sunday", "Monday", "Tuesday",};
    int day[12] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};

    cin >> a >> b;

    while (a != 0 && b != 0) {
        b += day[a-1];
        cout << date[b%7] << endl;
        cin >> a >> b;
    }

    return 0;
}

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

int day[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string dateString[7] = {
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday",
    "Sunday"
};

int main() {
    int date[12][31];
    int cnt = 1;
    for (int i=0; i<12; ++i) {
        for (int j=0; j<day[i]; ++j) {
            if (i == 0 && j == 0) {
                date[i][j] = 3;
            } else if (j == 0) {
                date[i][j] = (date[i-1][day[i-1] - 1] + 1) % 7;
            } else {
                date[i][j] = (date[i][j-1] + 1) % 7;
            }
            cnt ++;
        }
    }

    int m, d;
    while (cin >> m >> d, m && d) {
        cout << dateString[date[m-1][d-1]] << endl;
    }
    return 0;
}

C++: #include <cstdio>

using namespace std;

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

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

    int acc_days = 0;
    for (int i = 0; i < month; ++i) { acc_days += days[i]; }
    acc_days += day;
    puts(wdays[acc_days % 7]);
  }

  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 <iostream>
#include <cmath>
using namespace std;

char const* data1[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
int data2[] = {3, 6, 0, 3, 5, 1, 3, 6, 2, 4, 0, 2};

int main(void)
{
    int m, d;
    while (cin >> m >> d && m!=0 && d!=0) {
        int a = (data2[m-1] + d-1)%7;
        cout << data1[a] << endl;;
    }
    return 0;
}