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

int main()
{
	while(1)
	{
		int h=20,y=4,m,d,W,ans;
		char *youbi[7]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
		cin>>m>>d;
		if(m==0)break;
		if(m<3)
		{
			y--;
			m+=12;
		}
		W=(y+y/4-y/100+y/400+(13*m+8)/5+d)%7;
		cout<<youbi[W]<<endl;
	}
	return 0;
}

C++: #include<stdio.h>

int Zeller(int,int,int);

int main(void){
  int i,j,sum,a,b;
  
  while(1){
    sum=0;
    scanf("%d %d",&a,&b);
    if(a==0 && b==0)break;

    switch(Zeller(2004,a,b)){
    case 0:
      printf("Sunday\n");
      break;
    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;
    }
  }
  return 0;
}

int Zeller(int year, int month, int day){
    if (month<3) {
        year--;
        month += 12;
    }
    return (year + year/4 - year/100 + year/400
            + (13*month+8)/5 + day) % 7;
}

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,29,
		 31,30,
		 31,30,
		 31,31,
		 30,31,
		 30,31};
  while(cin>>aa>>b,aa+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>
#include<cstdio>

using namespace std;

int Month;
int Day;

const char *data[7] ={
  "Monday",
  "Tuesday",
  "Wednesday",
  "Thursday",
  "Friday",
  "Saturaday",
  "Sunday"
};
const int days[12] = {31,29,31,30,31,30,31,31,30,31,30,31};

int ans[12][31];
int main(int argc, char *argv[])
{
  while(scanf("%d %d",&Month,&Day)){
      int d = 3;
    if(Month == 0)
      break;
    for(int i = 0;i < 12;i++){
      for(int j = 0;j < days[i];j++){
	ans[i][j] = d%7;
	d++;
      }
    }
    cout <<data[ans[Month-1][Day-1]]<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int fairfield(int y,int m,int d)
{
	if(m<=2){
		y--;
		m+=12;
	}
	return 365*y+y/4-y/100+y/400+153*(m+1)/5+d-428;
}

int main()
{
	string weekday[7]={"Sunday","Monday","Tuesday","Wednesday","Thursday", "Friday", "Saturday"};
	for(int m,d;cin>>m>>d,m|d;)
		cout<<weekday[fairfield(2004,m,d)%7]<<endl;
	
	return 0;
}

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

int m,d;
int data[] = {31,29,31,30,31,30,31,31,30,31,30,31};
string day[] = {"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};

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

		for(int i = 0; i < m - 1; i++){
			d+=data[i];
		}
		cout << day[(d-1)%7] << endl;
	}
}

C++: #include<iostream>
#include<string>
using namespace std;
const string day[] = {"Thurs", "Fri", "Satur", "Sun", "Mon", "Tues", "Wednes"};

int main(){
  int m, d;
  while(cin >> m >> d, m != 0 || d != 0) {
    int days = d - 1;
    for(int i = 1; i < m; i++) { 
    if(i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12)  days += 31;
    else if(i == 4 || i == 6 || i == 9 || i == 11) days += 30;
    else days += 29;
    }
    cout << day[days % 7] << "day" << endl;
  }
  return 0;
}

C++: #include<stdio.h>

int main(void){
	int m,d,now;
	char da[7][15]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
	for(;;){
		now=0;
		scanf("%d %d",&m,&d);
		if(!m||!d)break;
		for(int i=1;i<m;i++){
			now+= i==2 ? 29 : (i<8 ? 30+i%2 : 31-i%2);
		}
		now+=d;
		printf("now= %d\n",now);
		printf("%s\n",&da[now%7]);
	}
	return 0;
}

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

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

int main(){
	int M, D;
	while( cin >> M >> D, M ){
		int d = 3;
		for(int i=0; i<M-1; i++ ){
			d += month[i];
		}
		d += D;
		d %= 7;
		cout << date[d] << endl;
	}
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main()
{
  int calen[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
  int month,day;
  int ans = 0;

  while(cin >> month >> day){
    if(month == 0)break;
    
    ans = 0;

    for(int i = 0;i < month-1;i++){
      ans += calen[i];
    }

    ans += day;
    cout << ans << endl;

    switch (ans % 7) {
    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;
      break;
    }

  }
}

C++: #include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>
#include<array>

using namespace std;

int main()
{
  array<int,13> ma = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

  int m, d, yd;

  while ( cin >> m >> d && ( m != 0 || d != 0 ))
    {
      yd = 0;
      for ( int i = 1; i < m; ++i )
        yd += ma[i];
      yd += d;

      int wd = yd % 7;

      switch ( wd )
        {
        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;
          break;
        }          
    }
  return 0;
}

C++: #include <stdio.h>
  int main(){
int i,j;
int x[12]={0,31,60,91,121,152,182,213,243,274,304,335};
int n,m;
while(1){
scanf("%d%d",&n,&m);
if(n==0){
break;
}
int q=(x[n-1]+m)%7;
if(q==0){
printf("Wednesday\n");
}else if(q==1){
printf("Thursday\n");
}else if(q==2){
printf("Friday\n");
}else if(q==3){
printf("Saturday\n");
}else if(q==4){
printf("Sunday\n");
}else if(q==5){
printf("Monday\n");
}else if(q==6){
printf("Tuesday\n");
}
}
return 0;
}