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;

string dow[] = {
  "Monday",
  "Tuesday",
  "Wednesday",
  "Thursday",
  "Friday",
  "Saturday",
  "Sunday"
};
int month[] = {
  31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};

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

    int day = 0;
    for (int i = 0; i < m; i++) {
      day += month[i];
    }
    day += d;
    day += 3;
    day %= 7;

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

  return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <iomanip>
using namespace std;
int main(){
  int m,d,mlist[12]={31,29,31,30,31,30,31,31,30,31,30,31},dsum;
  string res;
  while(cin>>m>>d){
    dsum=0;
    if(!m)return 0;
    for(int i=0;i<m;i++){
      dsum+=(i+1!=m)?mlist[i]:d;
    }
    //1 Thur 2 Fri 3 Satu 4 Sun 5 Mon 6 Tues 0 Wed
    switch(dsum%7)
      {
      case 0:
	res="Wednesday";
	break;
      case 1:
	res="Thursday";
	break;
      case 2:
	res="Friday";
	break;
      case 3:
	res="Saturday";
	break;
      case 4:
	res="Sunday";
	break;
      case 5:
	res="Monday";
	break;
      case 6:
	res="Tuesday";
	break;
      }
    cout<<res<<endl;
  }
}

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

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int const MOD = 1000000007;

int dayOfTheWeek( int y, int m, int d )
{
    if( m < 3 ) {
        y--; m += 12;
    }
    return ( y + y/4 - y/100 + y/400 + ( 13*m + 8 )/5 + d )%7;
}

int main() {
    string dayname[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
    int m,d;
    while(cin >> m, m) {
        cin >> d;
        cout << dayname[dayOfTheWeek(2016,m,d)] << endl;
    }
    return 0;
}

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

int main(){
	int month[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	int m,d;
	while(cin>>m>>d,m+d){
		int sum=d;
		for(int i=0;i<m-1;i++){
			sum+=month[i];
		}	
		switch(sum%7){
			case 1:cout<<"Thursday";break;
			case 2:cout<<"Friday";break;
			case 3:cout<<"Saturday";break;
			case 4:cout<<"Sunday";break;
			case 5:cout<<"Monday";break;
			case 6:cout<<"Tuesday";break;			
			case 0:cout<<"Wednesday";break;
		}
		cout<<endl;
		
	}
}

C++: #include <iostream>
using namespace std;
int main(){
	int m,d;
	while(cin>>m>>d){
		if(!m) break;
		int daym[12]={0,31,60,91,121,152,183,213,244,274,305,335};
		int wd = (daym[m-1] + d + 2)%7;
		switch(wd){
		case 0:
			cout <<"Monday"<<endl;
			break;
		case 1:
			cout<<"Tuesday"<<endl;
			break;
		case 2:
			cout<<"Wednesday"<<endl;
			break;
		case 3:
			cout<<"Thursday"<<endl;
			break;
		case 4:
			cout<<"Friday"<<endl;
			break;
		case 5:
			cout<<"Saturday"<<endl;
			break;
		case 6:
			cout<<"Sunday"<<endl;
			break;
		}
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<list>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

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

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

int main() {
	for (int m, d; cin >> m >> d&&m;) {
		while (m)
			d += b[--m];
		cout << a[(d - 1 + 3) % 7] << endl;
	}
	return 0;
}

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

using namespace std;
 
int main(){
	int m[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	string d[]={"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

	int x,y;

	while(scanf("%d %d", &x, &y) != EOF){
		if(0==x) break;
		int c=2;
		while(--x) c+=m[x];

		c+=y;
		cout<< d[c%7]<<endl;
	}

    return 0;
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)

const int month[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30};
int main()
{
  int m, d, cntdays = 0;
  
  while (cin >> m >> d, m + d){
    cntdays = month[m - 1] + d;
    switch (cntdats % 7){
      case 1:
        cout << Monday;
        break;
      case 2:
        cout << Tuesday;
        break;
      case 3:
        cout << Wednesday;
        break;
      case 4:
        cout << Thursday;
        break;
      case 5:
        cout << Friday;
        break;
      case 6:
        cout << Saturday;
        break;
      case 0:
        cout << Sunday;
        break;
      cout << endl;
    }
  }
}

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

int week(int m,int d){

  struct tm t;
  t.tm_year  = 104; // 2004 - 1900
  t.tm_mon   = m-1;
  t.tm_mday  = d;
  t.tm_hour  = 0;           
  t.tm_min   = 0;               
  t.tm_sec   = 0;               
  t.tm_isdst = -1;
  
  if (mktime(&t) == -1)
	return (-1);
  return(t.tm_wday);
}

int main(){
  int m,d;
  static string w[] = {"Sunday","Monday","Tuesday","Wednesday",
					   "Thursday","Friday","Saturday"};
  while(cin >> m >> d,m||d){
  cout << w[week(m,d)] << endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int dayl[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
  int today[2];
  int dayt=0;
  int ans;
  while(cin>>today[0]>>today[1]){
    if(today[0]==0&&today[1]==0) break;
    for(int i=0;i<today[0];i++) dayt += dayl[i];
    dayt += today[1];
    ans = dayt % 7;
    if(ans==1) cout << "Thursday" << endl;
    else if(ans==2) cout << "Friday" << endl;
    else if(ans==3) cout << "Saturday" << endl;
    else if(ans==4) cout << "Sunday" << endl;
    else if(ans==5) cout << "Monday" << endl;
    else if(ans==6) cout << "Tuesday" << endl;
    else  cout << "Wednesday" << endl;
    dayt = 0;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
	int i;
	int a, b;
	int day=0;
	int t;

	cin >> a;

	while(a != 0){
		if(a=1){
			day = day;
		}
		if(a=2){
			day = day + 31;
		}
		if(a=3){
			day = day + 60;
		}
		if(a=4){
			day = day + 91;
		}
		if(a=5){
			day = day + 121;
		}
		if(a=6){
			day = day + 152;
		}
		if(a=7){
			day = day + 182;
		}
		if(a=8){
			day = day + 213;
		}
		if(a=9){
			day = day + 244;
		}
		if(a=10){
			day = day + 274;
		}
		if(a=11){
			day = day + 305;
		}
		if(a=12){
			day = day + 335;
		}

		cin >> b;
		day = day + b;

		t = day % 7;
		if(t=1){
			cout << "Wednesday" << endl;
		}
		if(t=2){
			cout << "Thersday" << endl;
		}
		if(t=3){
			cout << "Friday" << endl;
		}
		if(t=4){
			cout << "Saturday" << endl;
		}
		if(t=5){
			cout << "Sunday" << endl;
		}
		if(t=6){
			cout << "Monday" << endl;
		}
		else{
			cout << "Tuesday" << endl;
		}
	}


}