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

int main()
{
	string week[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
	int day[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	vector<int> firstDay;
	int a, b;
	int i;

	firstDay.push_back(3);
	for (i = 0; i < 12; i++) {
		firstDay.push_back( (firstDay[i]+day[i])%7 );
	}

	while(cin>>a>>b, a||b) {
		cout<<week[ (firstDay[a-1] + b-1) % 7 ]<<endl;
	}

	return 0;
}

C++: #include<stdio.h>

void y(int x ){
	if(x == 0)
		puts("Thursday");
	else if(x == 1)
		puts("Friday");
	else if(x == 2)
		puts("Saturday");
	else if(x == 3)
		puts("Sunday");
	else if(x == 4)
		puts("Monday");
	else if(x == 5)
		puts("Tuesday");
	else if(x == 6)
		puts("Wednesday");
}

int main(void){
	int M,D;
	while(1){
		int date = 0,ans;
		int m[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
		
		scanf("%d%d", &M, &D);
		if(M == 0 && D  == 0)break;
		for(int i = 1; i <= 12 ; i++){
			for(int j = 1; j <= m[i-1]; j++){
				if(i == M && j == D){
					ans = date;
				}
	//			printf("%d%dú%d\n",i,j,date%7);
	//			y(date%7);
				date++;
			}
		}
		y(ans%7);
	}
	
	return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int hoge[] = {31,29,31,30,31,30,31,31,30,31,30,31};
  string s[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

  int foo[12][31];
  int dd = 3;
  for (int i=0; i<12; i++) {
    for (int j=0; j<hoge[i]; j++) {
      foo[i][j] = dd%7;
      dd++;
    }
  }
  
  int m, d;
  while(cin >> m >> d, m+d) {
    cout << s[foo[m-1][d-1]] << endl;
  }
}

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

C++: import java.util.*;
public class Main {
	static String[] Day=new String[10];
	public static void setDay(){
		Day[0]="Wednesday";
		Day[1]="Thursday";
		Day[2]="Friday";
		Day[3]="Saturday";
		Day[4]="Sunday";
		Day[5]="Monday";
		Day[6]="Tuesday";
	}
	static int[] Month=new int[20];
	public static void setMonth(){
		Month[1]=31;
		Month[2]=29;
		Month[3]=31;
		Month[4]=30;
		Month[5]=31;
		Month[6]=30;
		Month[7]=31;
		Month[8]=31;
		Month[9]=10;
		Month[10]=31;
		Month[11]=30;
		Month[12]=31;
	}
	public static void main(String args[]){
		setDay();
		setMonth();
		Scanner in=new Scanner(System.in);
		int date,month,days;
		while(in.hasNextInt()){
			month=in.nextInt();
			date=in.nextInt();
			if(month==0&&date==0)
				break;
			days=0;
			for(int i=1;i<month;i++)
				days+=Month[i];
			days+=date;
			System.out.println(Day[days%7]);
		}
		in.close();
	}
}

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

int main()
{
	string week[] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	int month[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	int m, d;
	while (cin >> m >> d && m != 0 || d != 0)
	{
		int w = 3 - 1;
		bool f = false;
		for (int i = 1; i <= 12; i++)
		{
			for (int j = 1; j <= month[i - 1]; j++)
			{
				w = (w + 1) % 7;
				if (i == m && j == d)
				{
					cout << week[w] <<endl;
					f = true;
					break;
				}
			}
			if (f)break;
		}
	}
	return 0;
}

C++: #include<iostream>

const char* ans[7] = {
	"Monday",
	"Tuesday",
	"Wednesday",
	"Thursday",
	"Friday",
	"Saturday",
	"Sunday"
};

int main(){

	int month, date;

	while (std::cin >> month >> date, month || date){
		int day = 2;

		for (int i = 1; i < month; i++){
			int numdate = 31;
			if (i == 4 || i == 6 || i == 9 || i == 11)numdate = 30;
			else if (i == 2)numdate = 29;

			day = (day + numdate) % 7;
		}

		day = (day + date) % 7;

		std::cout << ans[day] << std::endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int main(){
	int a,b,month[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	string week[]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
	while(cin>>a>>b){
		if(a==0 && b==0)break;
		for(int i=1;i<a;i++){
			b+=month[i];
		}
		cout<<week[b%7]<<endl;
	}
	return 0;
}

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

int main()
{
	std::vector<std::string> day_of_week{
		"Thursday",
		"Friday",
		"Suterday",
		"Sunday",
		"Monday",
		"Tuesday",
		"Wednesday"
	};

	std::vector<int> day_num_of_month{
		31,
		29,
		31,
		30,
		31,
		30,
		31,
		31,
		30,
		31,
		30,
		31
	};

	int month = 0;
	int day = 0;

	while (std::cin >> month >> day)
	{
		if (0 == month) { break; }

		int days_elapsed = 0;
		for (int m = 1; m < month; ++m)
		{
			days_elapsed += day_num_of_month[m - 1];
		}
		days_elapsed += day;

		std::cout << day_of_week[days_elapsed % 7 - 1] << std::endl;
	}

	return 0;
}

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

using namespace std;

int main(){
	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 && d == 0) break;

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

C++: #include <stdio.h>
#include <string.h>
#include <time.h>

int
main(void)
{
	char line[80];

	int m, d;
	
	while (true) {
		if (fgets(line, sizeof line, stdin) == NULL) {
			return 0;
		}
		if (sscanf(line, "%d %d", &m, &d) != 2) {
			return 0;
		}

		if (m == 0) {
			return 0;
		}
		
		struct tm tm0;
		memset(&tm0, 0, sizeof tm0);
		
		tm0.tm_year = 2004-1900;
		tm0.tm_mon = m - 1;
		tm0.tm_mday = d;

		time_t t = mktime(&tm0);
		
		struct tm* tm1 =localtime(&t);
		
		strftime(line, sizeof line, "%A", tm1);

		printf("%s\n", line);
	}

	return 0;
}

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

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