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++: // Zellerの公式

#include <iostream>
#include <cstring>
using namespace std;

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

void Day2004(int month, int day);

int main(void) {
    int month, day;
    
    while(cin >> month >> day) {
        if(month == 0 || day == 0) {
            break;
        }
        Day2004(month, day);
    }
}

void Day2004(int month, int day) {
    int y, m, d;
    int DayNumber;
    
    if(month == 1 || month == 2) {
        y = 2003;
        m = month + 12;
        d = day;
    } else {
        y = 2004;
        m = month;
        d = day;
    }
    
    DayNumber = 
        (y + (y / 4) - (y / 100) + (y / 400) + ((13 * m + 8) / 5) + d) % 7;
    
    cout << Day[DayNumber] << endl;
}

C++: #include <stdio.h>

int total[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30};

int Sum(int x) {
  int i, sum = 0;
  for(i = 0; i < x; i ++) {
    sum += total[i];
  }

  return sum;
}

int main() {
  int month, day;
  while(scanf("%d %d", &month, &day)) {
    if(month == 0) break;

    switch((Sum(month - 1) + day)%7) {
      case 0:
        printf("Thursday\n");
        break;

      case 1:
        printf("Friday\n");
        break;

      case 2:
        printf("Saturday\n");
        break;

      case 3:
        printf("Sunday\n");
        break;

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

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

    struct tm  t;
    t.tm_year  = 2004 - 1900;
    t.tm_hour  = 0;
    t.tm_min   = 0;
    t.tm_sec   = 0;
    t.tm_isdst = 0;

    for (int month, day; cin >> month >> day && (month || day);) {
        t.tm_mon   = month - 1;
        t.tm_mday  = day;
        mktime(&t);
        cout << weeks[t.tm_wday] << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
    string m = "Monday", tu = "Tuesday", w = "Wednesday", th = "Thursday", f = "Friday",
        sa = "Saturday", su = "Sunday";
    while(1) {
        int a=0, b=0;
        cin >> a >> b;
        if(a == 0 && b == 0)
            return 0;

        switch(a) {
        case 12:
            b += 30;
        case 11:
            b += 31;
        case 10:
            b += 30;
        case 9:
            b += 31;
        case 8:
            b += 31;
        case 7:
            b += 30;
        case 6:
            b += 31;
        case 5:
            b += 30;
        case 4:
            b += 31;
        case 3:
            b += 29;
        case 2:
            b += 31;
        default:
            ;
        }
        //cout << b << ' ';
        if(b % 7 == 0)
            cout << w << endl;
        if(b % 7 == 1)
            cout << th << endl;
        if(b % 7 == 2)
            cout << f << endl;
        if(b % 7 == 3)
            cout << sa << endl;
        if(b % 7 == 4)
            cout << su << endl;
        if(b % 7 == 5)
            cout << m << endl;
        if(b % 7 == 6)
            cout << tu << endl;
    }
}

C++: #include<iostream>
using namespace std;
int main(){
int m,d,h,y=4;
char w[][7]={"Satur","Sun","Mon","Tues","Wednes","Thurs","Fri"};
for(;;){
cin>>m>>d;
if(m==0)break;
if(m<3){m+=12;y--;}
h=(y+int(y/4)-35+int(2.6*(m+1))+d)%7;
cout<<w[h]<<"day"<<endl;
}
return 0;
}

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

using namespace std;

int main() {
    int m, d, past = 0;
    int day[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
    string week[] = { "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday" };
    while (cin >> m >> d, m != 0) {
        for (int i = 0; i < m - 1; i++) {
            past += day[i];
        }
        past += d - 1;
        cout << week[past % 7] << endl;
    }

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    while(true) {
        int m, d; cin >> m >> d;
        if (m == 0)
            break;
        
        vector<string> ans{"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};
        vector<int> months{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        m--;
        int days = 0;
        rep(i, m) {
            days+= months.at(i);
        }
        days+= d;

        cout << (ans.at(days % 7)) << endl;
    }
}

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

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

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int m,d;
  while(cin>>m>>d,m+d){
    int day = 0;
    // 2 , 4 , 6 , 9 . 11 
    int month[12] = {31,29,31,30,31,30,
		     31,31,30,31,30,31};
    rep(i,m){
      day+=month[i];
    }
    day=(day + d + 3)%7;
    switch(day){
    case 0:
      cout<<"Thursday"<<endl;
      break;
    case 1:
      cout<<"Friday"<<endl;
      break;
    case 2:
      cout<<"Saturday"<<endl;
      break;
    case 3:
      cout<<"Sunday"<<endl;
      break;
    case 4:
      cout<<"Monday"<<endl;
      break;
    case 5:
      cout<<"Tuesday"<<endl;
      break;
    case 6:
      cout<<"Wednesday"<<endl;
      break;
    }
    

  }
}