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

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

int main(){
	
	int m,d;
	
	while(scanf("%d %d",&m,&d),(m!=0)){
		for(int i=0;i<m;i++){
			d=d+month[i];
		}
		d=d%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;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
 int main()
{
	//arrays with number of days in month and the days names
    int days[] = {31,29,31,30,31,30,31,31,30,31,30,31};
    string week[7] = {"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
    int month, day;
    while(cin >> month >> day)//entering day
	{
		
        int n = 0;
        for(int i=1; i<month; ++i)
		{
            n += days[i-1];
        }
        n += day;
 
        n %= 7;
        cout << week[n] <<endl;//printing the day
 
    }
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <utility>
#include <functional>

using namespace std;

int m, d, A[13] = { 0,0,31,60,91,121,152,182,213,244,274,305,335 };
string s[7] = { "Wednesday", "Thursday","Friday","Saturday","Sunday","Monday","Tuesday" };
int main() {
	while (1) {
		cin >> m >> d;
		if (m == 0) break;
		cout << s[(A[m] + d) % 7] << endl;
	}
	return 0;
}

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

using namespace std;

int main(void){
  int a,b;

  int nday[15] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
  string ans[10] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

  while(true){
    scanf("%d%d", &a,&b);
    if(a == 0 && b == 0)
      break;
    
    int sum = 3;
    for(int i = 1; i < a; i++)
      sum += nday[i];
    sum += b;

    printf("%s\n", ans[sum%7].c_str());

  }
  return 0;
}

C++: #include<cstdio>

int main(){
	int a[] = {0,0,31,60,91,121,152,182,213,244,274,305,335,366};
	int m, d;
	char day[7][10] = {"Monday", "Tuesday", "Wednesday", "Thursday","Friday","Saturday","Sunday"};
	scanf("%d %d", &m, &d);
	while(m || d){
		printf("%s\n", day[(a[m] + d + 2) % 7]);
		scanf("%d %d", &m, &d);
	}
}

C++: #define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#define EPS 1e-10
using namespace std;
typedef long long llong;
void whatday(int x, int y) {
	if (x % 7 == y % 7)cout << "Monday" << endl;
	else if (x % 7 == (y + 1) % 7)cout << "Tuesday" << endl;
	else if (x % 7 == (y + 2) % 7)cout << "Wednesday" << endl;
	else if (x % 7 == (y + 3) % 7)cout << "Thursday" << endl;
	else if (x % 7 == (y + 4) % 7)cout << "Friday" << endl;
	else if (x % 7 == (y + 5) % 7)cout << "Saturday" << endl;
	else if (x % 7 == (y + 6) % 7)cout << "Sunday" << endl;
}
int main() {
	int m, d;
	while (cin >> m >> d&&m&&d) {
		int x = 0;
		if (m < 3) {
			x += (m - 1) * 31 + (d - 1);
			whatday(x, 4);
		}
		else {
			x += 31 + 29;// 3/1
			m -= 3; d--;
			x += 61 * (m / 2) + (m % 2) * 31 + d;
			whatday(x, 4);
		}
	}
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
    int mon,day,ans=0,answer=0,sum[13]={1,31,60,91,121,152,182,213,244,274,305,335,366};
    string date[8]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
    while(cin>>mon>>day){
        if(mon==0)break;
        mon=mon-1;
        if(mon>0){
            ans=day+sum[mon];
        }else{
            ans=day;
        }
        answer=ans%7;
        cout<<date[answer]<<endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

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

		rep(i, m-1)
			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;
		case 0:
			cout << "Wednesday" << endl;
			break;
		}
	}
}

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

int main() {
	string youbi[7] = {"Wednesday","Thursday","Friday","Suturday","Sunday","Monday","Tuesday"};
	int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
	
	int gathu,nichi;
	while ( cin >> gathu >> nichi,gathu ) {
		int keika = 0;
		for ( int i = 0; i < gathu-1; i++ ) {
			keika += month[i];
		}
		keika += nichi;
		
		cout <<  youbi[keika % 7] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

int main(){
	pair<int,int> hiduke;
	string table[12][31];
	string day[] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	int dayCounter = 3;


	for(int i = 0; i < 12; i++){
		if(i == 2){
			for(int j = 0; j < 29; j++){
				table[i][j] = day[dayCounter++];
				if(dayCounter % 7 == 0){
					dayCounter = 0;
				}
			}
		}
		else if(i == 4 || i == 6 || i == 9 || i == 11){
			for(int j = 0; j < 30; j++){
				table[i][j] = day[dayCounter++];
				if(dayCounter % 7 == 0){
					dayCounter = 0;
				}
			}
		}
		else{
			for(int j = 0; j < 31; j++){
				table[i][j] = day[dayCounter++];
				if(dayCounter % 7 == 0){
					dayCounter = 0;
				}
			}
		}
	}



	while(cin >> hiduke.first >> hiduke.second && hiduke.first != 0){
		cout << table[hiduke.first - 1][hiduke.second - 1] << endl;
	}

	return 0;
}