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>
using namespace std;

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

//Zeller's conguence

int main()
{
    int h, y, m, d;
    h = 20;
    y = 4;
    while (true)
    {
        cin >> m >> d;
        if (m == 0 && d == 0)
            break;
        if (m == 1 || m == 2)
        {
            m += 12;
            y--;
        }
        int r = 5 * h + h / 4;
        int w = {d + ((13 * (m + 1)) / 5) +
                 y + y / 4 + r + 5};

        int ans = w % 7 + 1;
        switch (ans)
        {
        case 7:
            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;
            break;
        }
    }
    return 0;
}

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

using namespace std;


int main() {
	// 各月の日数を定数として定義しておく
	// 最初に0があるのは
	// 1.配列のインデックスと月が異なるとややこしくなる
	// 2.1月の場合に例外的な処理をしなくていいようにするため
	const int offset_days[]{
		0,31,29,31,30,31,30,31,31,30,31,30,31
	};
	const char* day_str[]{
		"Monday",
		"Tuesday",
		"Wednesday",
		"Thursday",
		"Friday",
		"Saturday",
		"Sunday"
	};
	// 処理を簡単にするため、前年の大晦日を起点に考える
	const int day_12_31 = 2;

	int m, d;
	while (cin >> m >> d, m != 0) {
		// 各月の日数の和を求める。
		// オフセットとして前年の大晦日に対応する値を設定する。
		int sum = std::accumulate(&offset_days[0], &offset_days[m], day_12_31);
		// 該当する日の曜日を求めるため、日数を加算して7で割ったあまりを求める。
		int day = (sum + d) % 7;
		cout << day_str[day] << endl;
	}

	return 0;
}

C++: //2004 366 1/1 Thursday

#include <cstdio>

using namespace std;

void today(int mon, int day);

int main()
{
	int mon, day;
	
	while (1){
		scanf("%d %d", &mon, &day);
		
		if (mon == 0){
			break;
		}
		
		today(mon, day);
	}
	
	return (0);
}

void today(int mon, int day)
{
	int tmp = 0;
	
	for (int i = 1; i < mon; i++){
		if (i == 4 || i == 6 || i == 9 || i == 11){
			tmp += 30;
		}
		else if (i == 2){
			tmp += 29;
		}
		else {
			tmp += 31;
		}
	}
	
	switch ((tmp + day) % 7){
	  case 0:
	    puts("Wednesday");
		break;
		
	  case 1:
	    puts("Thursday");
		break;
		
	  case 2:
	    puts("Friday");
		break;
		
	  case 3:
	    puts("Saturday");
		break;
		
	  case 4:
	    puts("Sunday");
		break;
		
	  case 5:
	    puts("Monday");
		break;
		
	  case 6:
	    puts("Tuesday");
		break;
	}
}

C++: //2004??´???366??\ /1/1 Thursday

#include <cstdio>

using namespace std;

void today(int mon, int day);

int main()
{
	int mon, day;
	
	while (1){
		scanf("%d %d", &mon, &day);
		
		if (mon == 0){
			break;
		}
		
		today(mon, day);
	}
	
	return (0);
}

void today(int mon, int day)
{
	int tmp = 0;
	
	for (int i = 1; i < mon; i++){
		if (mon == 4 || mon == 6 || mon == 9 || mon == 11){
			tmp += 30;
		}
		else if (mon == 2){
			tmp += 29;
		}
		else {
			tmp += 31;
		}
	}
	
	switch ((tmp + day) % 7){
	  case 0:
	    puts("Wednesday");
		break;
		
	  case 1:
	    puts("Thursday");
		break;
		
	  case 2:
	    puts("Friday");
		break;
		
	  case 3:
	    puts("Saturday");
		break;
		
	  case 4:
	    puts("Sunday");
		break;
		
	  case 5:
	    puts("Monday");
		break;
		
	  case 6:
	    puts("Tuesday");
		break;
	}
}

C++: #include<iostream>
using namespace std;
int main()
{
int day,month,day
while(cin>>month>>day&&month!=0)
{	
switch(m)
{
cace 1
switch(date%7)
{
case 1;
day=4;
break;
case 2;
day=5;
break;
case 3;
day=6;
break;
case 4;
day=7;
break;
case 5;
day=1;
break;
case 6;
day=2;
break;
case 0;
day=3;
break;
}
break;
case 2
switch(date%7)
{
case 1;
day=7;
break;
case 2;
day=1;
break;
case 3;
day=2;
break;
case 4;
day=3;
break;
case 5;
day=4;
break;
case 6;
day=5;
break;
case 0;
day=6;
break;
}
break;
case 3
switch(date%7)
{
case 1;
day=1;
break;
case 2;
day=2;
break;
case 3;
day=3;
break;
case 4;
day=4;
break;
case 5;
day=5;
break;
case 6;
day=6;
break;
case 0;
day=7;
break;
}
break;
case 4
switch(date%7)
{
case 1;
day=4;
break;
case 2;
day=5;
break;
case 3;
day=6;
break;
case 4;
day=7;
break;
case 5;
day=1;
break;
case 6;
day=2;
break;
case 0;
day=3;
break;
}
break;
case 5
switch(date%7)
{
case 1;
day=6;
break;
case 2;
day=7;
break;
case 3;
day=1;
break;
case 4;
day=2;
break;
case 5;
day=3;
break;
case 6;
day=4;
break;
case 0;
day=5;
break;
}
break;
case 6
switch(date%7)
{
case 1;
day=2;
break;
case 2;
day=3;
break;
case 3;
day=4;
break;
case 4;
day=5;
break;
case 5;
day=6;
break;
case 6;
day=7;
break;
case 0;
day=1;
break;
}
break;
case 7
switch(date%7)
{
case 1;
day=4;
break;
case 2;
day=5;
break;
case 3;
day=6;
break;
case 4;
day=7;
break;
case 5;
day=1;
break;
case 6;
day=2;
break;
case 0;
day=3;
break;
}
break;
case 8
switch(date%7)
{
case 1;
day=7;
break;
case 2;
day=1;
break;
case 3;
day=2;
break;
case 4;
day=3;
break;
case 5;
day=4;
break;
case 6;
day=5;
break;
case 0;
day=6;
break;
}
break;
case 9
switch(date%7)
{
case 1;
day=3;
break;
case 2;
day=4;
break;
case 3;
day=5;
break;
case 4;
day=6;
break;
case 5;
day=7;
break;
case 6;
day=1;
break;
case 0;
day=2;
break;
}
break;
case 10
switch(date%7)
{
case 1;
day=5;
break;
case 2;
day=6;
break;
case 3;
day=7;
break;
case 4;
day=1;
break;
case 5;
day=2;
break;
case 6;
day=3;
break;
case 0;
day=4;
break;
}
break;
case 11
switch(date%7)
{
case 1;
day=1;
break;
case 2;
day=2;
break;
case 3;
day=3;
break;
case 4;
day=4;
break;
case 5;
day=5;
break;
case 6;
day=6;
break;
case 0;
day=7;
break;
}
break;
case 12
switch(date%7)
{
case 1;
day=3;
break;
case 2;
day=4;
break;
case 3;
day=5;
break;
case 4;
day=6;
break;
case 5;
day=7;
break;
case 6;
day=1;
break;
case 0;
day=2;
break;
}
break;
}
switch(day)
{
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;
break;
case 7;
cout<<"Sunday"<<endl;
break;
}
}
return 0;
}

C++: #include<iostream>

int monthes(int i){
  if(i==2){
    return 29;
  }
  if(i==4||i==6||i==9||i==11){
    return 30;
  }else{
    return 31;
  }
}

int main(){
  int month,day,sum;

  while(std::cin >> month >> day){
    if(month==0){
      break;
    }
    sum = 0;
    for(int i=1;i<month;i++){
      sum += monthes(i);
    }
    sum += day-1;
    switch(sum%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;
    }
  }
}