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>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int day_month[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
char day[10][10]={
  {"Thursday"},
  {"Friday"},
  {"Saturday"},
  {"Sunday"},
  {"Monday"},
  {"Tuesday"},
  {"Wednesday"},
};
int main(){
  int m,d,count;
  while(1){
    cin >> m >> d;
    if(!m && !d)break;
    count = -1;
    for(int i=1;i<=m;i++){
      if(i == m){
	for(int j=1;j<=d;j++){
	  count++;
	}
      }else {
	for(int j=1;j<=day_month[i];j++){
	  count++;
	}
      }
    }
    cout << day[count % 7] << endl;
  }
}

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

int main()
{
	int month[] = {
		0, 31, 29, 31, 30, 31, 30,
		31, 31, 30, 31, 30, 31
	};
	int m, d;
	while(cin >> m >> d){
		if(m == 0) break;
		int days = 0;
		for(int i = 1; i < m; i++) days += month[i];
		days += d;
		days = days % 7;
		switch(days){
		case 0: cout << "Wednesday" << endl; break;
		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;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<iomanip>
 
#define EPS (1e-10)
using namespace std;
#define PI (3.1415926535)

int main(){
	string day[] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};

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

	int m, d;
	while(cin >> m >> d){
		if(m == 0 && d == 0){
			break;
		}
		for(int i = 1; i < m; i++){
			d += month[i];
		}

		cout << day[d%7] << endl;
	}

	return 0;
}

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

int main()
{
  int m,d;
  string week[7] = {"Thursday", "Friday", "Saturday", "Sunday","Mondy", "Tuesday", "Wednesday"};
  int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  
  while (scanf("%d %d", &m, &d)) {
    if (m+d == 0) { break; };
    int day = 0;
    for (int i = 0; i < (m - 1); i++) {
      day += month[i];
    }
    day += d;
    cout << week[(day%7)-1] << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;


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

int main() 
{
    for(int i = 0; i < 12; i++){
        for(int j = 0; j < 31; j++){
            date[i][j] = 0;
        }
    }
    for(int i = 0; i < 12; i++){
        if(i == 3 || i == 5 || i == 8 || i == 10){
            for(int j = 0; j < 30; j++){
                date[i][j] = 1;
            }
        }else if(i == 1){
            for(int j = 0; j < 29; j++){
                date[i][j] = 1;
            }
        }else{
            for(int j = 0; j < 31; j++){
                date[i][j] = 1;
            }
        }
    }
    while(true){
        int cnt = 0;
        int m,d;
        cin >> m >> d;
        if(m==0 && d == 0) break;
        m--; d--;
        for(int i = 0; i < 12; i++){
            for(int j = 0; j < 31; j++){
                if((i < m || (i == m && j <= d)) && date[i][j] == 1){
                    cnt++;
                }
            }
        }
        cnt += 2;
        cout << day[cnt%7] << 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,a+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<iostream>
using namespace std;
int subZeller(int m,int d){
	int y=2004;
	if(m<3){
		y--;
		m+=12;
	}
	return(y+y/4-y/100+y/400+(13*m+8)/5+d)%7;
}

int main(){
	
	int month,day;
	char *dayname[]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
	while(cin>>month>>day){
		if(month!=0&&day!=0){
			cout<<dayname[subZeller(month,day)]<<endl;
		}
		else
			break;
	}
}

C++:  
 #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int month[12]={31,29,31,30,31,30,31,31,30,31,30,31};
  
 int main()
 {
   int m,d;
   int duration;
   while(cin>>m>>d)
   {
     duration=0;
     if(m==0&&d==0) break;
     else
     {
       if(m==1) duration=d-1;
       else 
       {
         for(int i=0;i<m-1;i++) duration+=month[i];
         duration+=(d-1);     
       }    
       if(duration%7==0) cout<<"Thursday"<<endl;
       else if(duration%7==1) cout<<"Friday"<<endl;
       else if(duration%7==2) cout<<"Saturday"<<endl;
       else if(duration%7==3) cout<<"Sunday"<<endl;
       else if(duration%7==4) cout<<"Monday"<<endl;
       else if(duration%7==5) cout<<"Tuesday"<<endl;
       else cout<<"Wednesday"<<endl;
     }                
   }
   //while(1);     
   return 0;  
 }