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>

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,fuga;

	cin >> hoge >> fuga;

	int i;
	int count=0;

	if(hoge!=0)
	{
		for(i=0;i<hoge-1;i++)
		{
			count+=month[i];
		}	
		
		count+=fuga;

		int flag = 0;
	
		flag = count % 7;
		if(flag==0)
		{
			cout << "Wednesday" <<endl;
		}
		if(flag==1)
		{
			cout << "Thursday" <<endl;
		}
		if(flag==2)
		{
			cout << "Friday" <<endl;
		}
		if(flag==3)
		{
			cout << "Saturday" <<endl;
		}
		if(flag==4)
		{
			cout << "Sunday" <<endl;
		}
		if(flag==5)
		{
			cout << "Monday" <<endl;
		}
		if(flag==6)
		{
			cout << "Tuesday" <<endl;
		}
	}
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int main() {
	int day=0;
	int x,y;
	int md[12]={30,29,31,30,31,30,31,31,30,31,30,31};
	string s[7]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
	while(true){
		cin>>x>>y;
		if(x==0) break;
		for(int i=0;i<x-1;i++){
			day+=md[i];
		}
		day+=y;
		day%=7;
		cout<<s[day]<<endl;		
	}
}

C++: #include <iostream>

int main(){
    int m, d, w;
    int days[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    char *weekName[7] = {"Sunday", "Monday", "Tuesday", "Wednesday",
                         "Thursday", "Friday", "Saturday"};
    while(1){
        std::cin >> m >> d;
        if(!(m || d)){
            return 0;
        }
        w = 3;
        for(int i = 1; i < m; i++){
            w += days[i - 1];
        }
        w += d; 
        std::cout << weekName[w % 7] << std::endl;
    }
}

C++: #include<iostream>
#include <stdio.h>
#include <time.h>
#include<string>
using namespace std;
int main(){
  int f,i,p,count,s,q,type1,type2,type3,type4;
 for(;;){
      count=0;
      s=0;
      p=0;
       q=0;
     cin>>f;
      type1=(f==1||f==10);type2=(f==2||f==3||f==11);type3=(f==4||f==7);type4=(f==9||f==12);
          cout<<"  S  M  T  W  t  F  s"<<endl;
          cout<<endl;
          if(type1){
              count=-1;
              cout<<"   ";
          }
          else if(type2){
          count=-4;
          cout<<"            ";
          }
          else if(type4){
          count=-6;
          cout<<"                  ";
          }
          else if(f==5){
          count=-2;
          cout<<"      ";
          }
          else if(f==6){
              count=-5;
          cout<<"               ";
          }
          else if(f==8){
          count=-3;
          cout<<"         ";
          }if(f==2){
           q=28;
           }
           else if(f==1||f==3||f==5||f==7||f==8||f==10||f==12){
           q=31;
           }    
           else if(f==4||f==6||f==9||f==11){
           q=30;
           }
          for(i=1;i<=37;i++){
              count++;
              if(count<1){
              continue;
              }
          printf("%3d",count);
          if(i%7==0){
          cout<<endl;
          }
          if(count==q){
              break;
              }
          }
          cout<<endl<<endl;
          }
 return 0;
}

C++: #include <stdio.h>

int m ;
int d ;
int dayc ;

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

int main ( )
{
	while ( scanf ( "%d %d" , &m , &d ) == 2 && m && d ) {
		dayc = 0 ;
		for ( int i = 0 ; i < m ; i++ ) {
			dayc += days[i] ;
		}
		dayc += d ;
		dayc-- ;
		dayc %= 7 ;
		switch ( dayc ) {
			case 0 :
				printf ( "Thursday\n" ) ;
				break ;
			case 1 :
				printf ( "Friday\n" ) ;
				break ;
			case 2 :
				printf ( "Saturday\n" ) ;
				break ;
			case 3 :
				printf ( "Sunday\n" ) ;
				break ;
			case 4 :
				printf ( "Monday\n" ) ;
				break ;
			case 5 :
				printf ( "Tuesday\n" ) ;
				break ;
			case 6 :
				printf ( "Wednesday\n" ) ;
				break ;
		}
	}
	return 0 ;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main() {
    int dates[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    string days[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

    int m,d;
    while (cin >> m >> d && m != 0 || d != 0) {
        int day = 2;
        for (int i=0; i<m-1; ++i) {
            day = (day + dates[i]) % 7;
        }
        day = (day + d) % 7;

        cout << days[day] << endl;
    }
}

C++: #include<iostream>
#include<string>
int main(){
	int month,day;
	const int monthday[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	const std::string week[7]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	const int a=3;
	while(1){
		std::cin>>month>>day;
		if(month==0)break;
		int sum=day+a;
		for(int i=0;i<month-1;i++)sum+=monthday[i];
		std::cout<<week[(sum-1)%7]<<std::endl;
	}
	return 0;
	/*
	月曜日 Monday
	火曜日 Tuesday
	水曜日 Wednesday
	木曜日 Thursday
	金曜日 Friday
	土曜日 Saturday
	日曜日 Sunday
	*/
}