Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func zeller(month, day int) int {
	year := 2004
	if month == 1 || month == 2 {
		year--
		month += 12
	}
	return (year + year/4 - year/100 + year/400 + (13*month+8)/5 + day)%7
}

func main() {
	scanner.Split(bufio.ScanWords)
	for {
		month := nextInt()
		day := nextInt()
		if month == 0 && day == 0{
			break
		}
		switch zeller(month, day) {
		case 0:
			fmt.Println("Sunday")
		case 1:
			fmt.Println("Monday")
		case 2:
			fmt.Println("Tuesday")
		case 3:
			fmt.Println("Wednesday")
		case 4:
			fmt.Println("Thursday")
		case 5:
			fmt.Println("Friday")
		case 6:
			fmt.Println("Saturday")
		}
	}
}

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

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

int main() {
    int m, d;
    while (cin >> m >> d, m && d) {
        int t = d + accumulate(day, day + m - 1, 0);
        cout << date[(t + 2) % 7] << endl;
    }
    return 0;
}

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

using namespace std;

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

int main()
{
  int month, day;
  while (scanf("%d %d ", &month, &day) == 2) {
    if (month == 0 && day == 0) {break;}
    int sumday = 0;
    for (int i = 0; i < month - 1; i++) {
      sumday += mday[i];
    }
    sumday += day;
    cout << cal[(sumday + 2) % 7] << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int month, day, youbi;

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

		int year = 2004;
		
		if(month == 1){
			year = 2003;
			month = 13;
		}
		if(month == 2){
			year = 2003;
			month = 14;
		}

		year %= 100;

		youbi = (day + ((26*(month+1))/10) + year + (year/4) - 2*(year/100) + (year/100)/4);

		switch(youbi%7)
		{
			case 1: cout << "Sunday" << endl; break;
			case 2: cout << "Monday" << endl; break;
			case 3: cout << "Tuesday" << endl; break;
			case 4: cout << "Wednesday" << endl; break;
			case 5: cout << "Thursday" << endl; break;
			case 6: cout << "Friday" << endl; break;
			case 0: cout << "Saturday" << endl; break;
		}
	}

	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 99999999



int main(){
    int a,b;
    int month[]={0,0,31,29,31,30,31,30,31,31,30,31,30,31};
    for(int i=1;i<=12;i++)month[i]=month[i]+month[i-1];
    string w[]={"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
    while(cin>>a>>b){
        if(a==0&&b==0)break;
        int sum=0;
        sum+=month[a];
        sum+=b-1;
        sum=sum%7;
        cout<<w[sum]<<endl;
    }
}

C++: #include <stdio.h>
int main()
{
	char yobi[7][10]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Sunday"};
	int month,day;
	while(1){
		scanf("%d %d",&month,&day);
		if(month==0)
			break;
		for(int i=0;i<month;i++){
			switch(i){
				case 2:
					day+=29;
				case 4:
				case 6:
				case 9:
				case 11:
					day+=30;
				default:
					day+=31;
			}
		}
		printf("%s\n",yobi[day%7]);
	}
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
  int d[]={31,29,31,30,31,30,31,31,30,31,30,31};
  string s[]={"Thursday",
	      "Friday","Saturday","Sunday","Monday","Tuesday","Wednesday",};
  int i,j;
  int a,b;
  cin>>a>>b;
  while(a!=0){
    int o=0;
    for(i=1;i<a;i++) o+=d[i-1];
    o+=b-1;
    //cout << o << endl;
    cout << s[o%7] << endl;
    cin>>a>>b;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
 
int main(){
  string y[7]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
  int num[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 += num[m-1];
      m--;
    }
    cout << y[d%7] << endl;
  }
 
  return 0;
}

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

int main() {
  while (true) {
    int m, d; cin >> m >> d;
    if (m == 0 && d == 0) break;
    int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};

    for (int i = 0; i < m - 1; i++) d += month[i];

    switch (d % 7) {
    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;
    default:
      cout << "Wednesday" << endl;
      break;
    }
  }

  return 0;
}

C++: #include<iostream>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll;

const int MNUM = 12, leapMNUM = 12;
const int ML[] = {31,28,31,30,31,30,31,31,30,31,30,31};      //day/month in usual year
const int leapML[] = {31,29,31,30,31,30,31,31,30,31,30,31};  //day/month in leap year
const string days[] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};

struct date{
  int y,m,d;

  date(void):y(0),m(1),d(1){}
  date(int a,int b,int c):y(a),m(b),d(c){}
  
  bool isLeap(void){
    if(y%400==0)return true;
    if(y%100==0)return false;
    if(y%4==0)return true;
    return false;
  }

  date next(void){
    d++;
    if(isLeap()){
      if(leapML[m-1]<d){ d=1; m++; }
      if(leapMNUM<m){ m=1; y++; }
    }else{
      if(ML[m-1]<d){ d=1; m++; }
      if(MNUM<m){ m=1; y++; }
    }
    return *this;
  }

  bool operator==(const date x)const{return (y==x.y && m==x.m && d==x.d);}

  bool operator<(const date x)const{
    if(y!=x.y)return y<x.y;
    if(m!=x.m)return m<x.m;
    return d<x.d;
  }

  bool operator<=(const date x)const{return (*this==x || *this<x); }
  bool operator>(const date x)const{return !(*this<=x);}
  bool operator>=(const date x)const{return !(*this<x);}

  ll dayCount(void)const{
    date tmp;
    for(ll res=0;;res++){
      if(tmp==*this)return res;
      tmp.next();
    }
    return 0;
  }

  ll operator-(const date x)const{
    return dayCount() - x.dayCount();
  }

  //calculate days from Julian Day(-4713/01/01) using Fliegel's formula.
  ll Fliegel(void){
    int a = (14-m)/12, Y = y+4800-a, M = m+12*a-3;
    return (ll)d + (153*M+2)/5 + 365*Y + Y/4 - Y/100 + Y/400 - 32045;
  }

  //calculate day of week using Zeller congruence.
  int Zeller(void){
    int Y = y, M = m;
    if(M<3){ Y--; M+=12; }
    return (Y + Y/4 - Y/100 + Y/400 + (13*M+8)/5 + d)%7;
  }
};

int main(){
  int m,d;
  while(cin >> m >> d,m||d)
    cout << days[date(2004,m,d).Zeller()] << endl;
}

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

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

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

int main() {
	ios :: sync_with_stdio(false);
	while(true) {
		int m, d; cin >> m >> d;
		if(!m && !d) break;
		int s = d;
		for(int i = 1; i < m; i ++)
			s += day[i];
		cout << str[(s + 2) % 7] << '\n';
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main( void )
{
  char *s[] = { "Monday", "Tuesday", "Wednesday",
    "Thursday", "Friday", "Saturday", "Sunday" };
  int n[] = { 0,31,29,31,30,31,30,31,31,30,31,30,31 };
  int m,d,r,i;
  while( 1 ){
    cin >> m >> d;
    if( m==0 ) break;
    r=0;
    for( i=1; i<m; i++ ) r += n[i];
    r += d;
    cout << s[(r+2)%7] << endl;
  }
  return 0;
}