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 "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int T[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	string S[7]={"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
	while(true){
		int M=in(),D=in();
		if(M==0) break;
		int H=0;
		REP(i,M-1){
			H += T[i];
		}
		H+=D-1;
		H%=7;
		out(S[H]);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int m,d,n=0,date[50]={0},i=0;
	while(cin>>m&&m!=0){
		cin>>d;
		switch(m){
			case 1:
				break;
			case 2:
				d=d+3;
				break;
			case 3:
				d=d+4;
				break;
			case 4:
				d=d+3;
				break;
			case 5:
				d=d+6;
				break;
			case 6:
				d=d+1;
				break;
			case 7:
				d=d+4;
				break;
			case 8:
				break;
			case 9:
				d=d+2;
				break;
			case 10:
				d=d+5;
				break;
			case 11:
				break;
			case 12:
				d=d+3;
				break;
		}
		date[i]=d%7;
		i++;
		n++;
	}
	for(int i=0;i<n;i++){
		switch(date[i]){
			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 "bits/stdc++.h"
using namespace std;

int main() {
	long long X[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	string Y[7] = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
	long long M, D;
	while (cin >> M >> D) {
		if (M == 0 && D == 0) return 0;
		M--, D--;
		long long NM = 0, ND = 0, COUNT = 3;
		while (1) {
			if (NM == M && ND == D) break;
			COUNT++;
			ND++;
			if (ND == X[NM]) NM++, ND = 0;
		}
		cout << Y[COUNT % 7] << endl;
	}
}

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

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

int md[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

int main() {

  int m,d;
  while(true) {
    cin>>m>>d;
    if(!m&&!d) break;

    int res=0;
    for(int i=0; i<m-1; i++)
      res += md[i];

    res += d;

    cout<<days[res%7]<<endl;
  }
}

C++: #include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	int y, m, d, w;
	
	char* str[7] = {"Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur"};
	
	while(1){
		cin >> m >> d;
		y = 2004;
		if(m == 0){
			break;
		}
		if(m == 1 || m == 2 ){
			y--;
			m += 12;
		}
		w = (y+y/4-y/100+y/400+(13*m+8)/5+d)%7;

		cout << str[w] << "day" << endl;
	}
	
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
    string daystr[] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};
    int day[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30};
    int m, d;
    while(cin >> m >> d && m){
        for(int i = 0; i < m; i++){
            d += day[i];
        }
        cout <<  daystr[d % 7] << "\n";
    }
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>

#define ll long long int

using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int month,date;
  int n[12]={31,29,31,30,31,30,31,31,30,31,30,31};
  int i;

  while(1){
    cin>>month>>date;
    if(month==0)break;
    int day=0;
    for(i=0;i<month-1;i++)
      day+=n[i];
    day+=date;

    switch(day%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 <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,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 <string>
using namespace std;

int main()
{
	string days[]={
		"Mon",
		"Tues",
		"Wednes",
		"Thurs",
		"Fri",
		"Satur",
		"Sun"
	};
	int cal[12][31]={{0}};
	int today=3;
	for (int i=0; i<12; i++) {
		for (int j=0; j<31; j++) {
			cal[i][j]=today;
			++today%=7;
			if (i==3 || i== 5 || i==8 || i==10) {
				if (j==29) {
					break;
				}
			}
			else if (j==1) {
				if (j==28) {
					break;
				}
			}
		}
	}
	int a,b;
	for (cin >> a >> b; a || b; cin >> a >> b) {
		cout << days[cal[a-1][b-1]] << "day" << endl;
	}	
}

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

int main()
{
	int am[13] = {0, 31,29,31,30,31,30,31,31,30,31,30,31 };
	int a, b;

	while (cin >> a >> b&&a!=0&&b!=0)
	{
		

		static int c;
		for (int i = 0; i < a; i++) {
			c += am[i];
		}
		c += b;
		int d = c % 7;

		switch (d) {
		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<iostream>
using namespace std;
void daysel(int x){
  switch(x % 7){
  case 6:
  cout << "Tuesday"<<endl; break;
  case 7:
  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;
  }
}
void daycal(int month,int day){
  int x;
  switch(month){
  case 1:
  x = day; break;
  case 2:
  x = 31 + day; break;
  case 3:
  x = 60 + day; break;
  case 4:
  x = 91 + day; break;
  case 5:
  x = 121 + day; break;
  case 6:
  x = 152 + day; break;
  case 7:
  x = 182 + day; break;
  case 8:
  x = 213 + day; break;
  case 9: 
  x = 244 + day;break;
  case 10:
  x = 274 + day;break;
  case 11: 
  x = 305 + day; break;
  case 12:
  x = 335 + day; break;
  }
  daysel(x);

    }
int main(){
  int month,day;
  while(cin >> month >> day && !(month == 0 && day ==0)){   
      daycal(month,day);
  }  
  
}