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>

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", "Sat", "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>
#include<string>
using namespace std;

int m,d;
int data[] = {31,29,31,30,31,30,31,31,30,31,30,31};
string day[] = {"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};

int main(){
	while(cin >> m >> d){
		if(m == 0 && d == 0) break;

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

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
  int M[13]={0,31,60,91,121,152,182,213,244,274,305,335,366};
  string S[7]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
  int m,d;
  while(cin>>m>>d,m){
    int index=M[m-1]+d;
    cout<<S[index%7]<<endl;
  }
  return 0;
}

C++: #include<stdio.h>
int main()
{
int p[12]={31,29,31,30,31,30,31,31,30,31,30,31};
int M,D,sum;
while(1)
{
sum=0;
scanf("%d",&M);
scanf("%d",&D);if(M==0)break;
if(M==0)break;
for(int i=0;i<M-1;i++)
sum+=p[i];

sum+=D;

switch(sum%7)
{
case 4:
printf("Sunday\n");break;
case 5:
printf("Monday\n");break;

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

case 0:
printf("Wednesday\n");break;

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

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

case 3:
printf("Saturday\n");break;
}
}
return 0;
}

C++: #include<iostream>

using namespace std;

int mouth[]={-1,31,29,31,30,31,30,31,31,30,31,30,31};

int main(void){

	int mo,da,wa;

	while(1){
		wa=0;
		cin>>mo>>da;
		if(mo==0||da==0) break;
		for(int i=1;i<mo;i++) wa+=mouth[i];
		wa+=da;
		switch(wa%7){
		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;
		}
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

void count_num(int a,int b){
    string WDay[7] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
    int len[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
    int count = 0;
    for(int i = 0; i< a-1;i++){
        count += len[i];
    }
    count += b;
    cout << WDay[(count+2) % 7] << endl;
}

int main() {
    int a,b;
    while(cin >> a >>  b , a){
        count_num(a,b);
    }
    return 0;
}

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

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

int main(){
  int m, d;
  while(cin >> m >> d) {
    int days = d - 1;
    for(int i = 1; i < m; i++) { 
    if(i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12)
      days += 31;
    else if(i == 4 || i == 6 || i == 9 || i == 11)
      days += 30;
    else
      days += 29;
    }
    cout << day[days % 7] << "day" << endl;
  }
}

C++: #include<iostream>

using namespace std;

int main()
{
	int month[12];

	month[0]=31;
	month[1]=29;
	month[2]=31;
	month[3]=30;
	month[4]=31;
	month[5]=30;
	month[6]=31;
	month[7]=31;
	month[8]=30;
	month[9]=31;
	month[10]=30;
	month[11]=31;

	int hoge,fuge;

	cin >> hoge >> fuga;

	int i;
	int count=0;

	if(hoge!=0)
	{
		for(i=0;i<hoge-1;i++)
		{
			count+=month[i];
		}	
		
		count+=fuga;
	
		flag = count % 7;
		if(flag==0)
		{
			cout << "Wednesday" <<endl;
		}
		if(fkag==1)
		{
			cout << "Thursday" <<endl;
		}
		if(fkag==2)
		{
			cout << "Friday" <<endl;
		}
		if(fkag==3)
		{
			cout << "Saturday" <<endl;
		}
		if(fkag==4)
		{
			cout << "Sunday" <<endl;
		}
		if(fkag==5)
		{
			cout << "Monday" <<endl;
		}
		if(fkag==6)
		{
			cout << "Tuesday" <<endl;
		}
	}
}

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

using namespace std;
string a[7] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
int main(void){
  int aa,b;
  int mon[12] = {31,28,
		 31,30,
		 31,30,
		 31,31,
		 30,31,
		 30,31};
  while(cin>>aa>>b,aa+b){
    int d = b;
    for(int i = 0 ; i < aa-1 ; i ++){
      d += mon[i];
      cout<<d<<endl;
    }

    cout<<a[(d+2)%7]<<endl;
  }
  //*/
}

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

int main(){
	int m,d;
	while(true){
		cin >> m >> d;
		if(m == 0)break;
		int M = 1,D = 1;
		for(int i = 0; i < 366; i++){
			if(M == m && D == d){
				if(i % 7 == 0)cout << "Thursday" << endl;
				if(i % 7 == 1)cout << "Friday" << endl;
				if(i % 7 == 2)cout << "Saturday" << endl;
				if(i % 7 == 3)cout << "Sunday" << endl;
				if(i % 7 == 4)cout << "Monday" << endl;
				if(i % 7 == 5)cout << "Tuesday" << endl;
				if(i % 7 == 6)cout << "Wednesday" << endl;
			}
			D++;
			if((M == 1 || M == 3 || M == 5 || M == 7 || M == 8 || M == 10 || M == 12) && (D == 32)){
				M++;
				D = 1;
			}
			if((M == 4 || M == 6 || M == 9 || M == 11) && (D == 31)){
				M++;
				D = 1;
			}
			if(M == 2 && D == 30){
				M++;
				D = 1;
			}
		}
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

const int DAYS_NUM[12] =
  {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

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

int main() {
  int m, d;
  string day;
  while(1) {
    cin >> m >> d;
    if (m == 0) break;
    for (int i = 0; i < m - 1; i++)
      d += DAYS_NUM[i];
    d = (d + 2) % 7;
    cout << days[d] << endl;
  }
  return 0;
}

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

int main(){
  int M[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  string w[7] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};

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

    int tmp = d;
    for(int i=0; i<m; i++) tmp += M[i];

    cerr << tmp << endl;
    cout << w[tmp%7] << endl;
  }

  return 0;
}

C++: #include <stdio.h>

static int days[] = {
  0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30
};

static char* week[] = {
  "Monday",
  "Tuesday",
  "Wednesday",
  "Thursday",
  "Friday",
  "Saturday",
  "Sunday"
};

int main(void)
{
  int i;
  for (i=0; i<11; ++i) {
    days[i+1] += days[i];
  }

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

    day += days[month-1];
    day += 2;
    day %= 7;

    printf("%s\n", week[day]);
  }
  return 0;
}