Go: package main

import "fmt"

func main() {
	days := [12]int{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
	weekday := [7]string{"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}

	for {
		var m, d int
		fmt.Scan(&m, &d)
		if m == 0 {
			break
		}

		for i := 0; i < m-1; i++ {
			d += days[i]
		}

		fmt.Println(weekday[d%7])
	}
}

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

using namespace std;

int main(void) {

	/*
	double x[3] = { 0,0,0 };
	double y[3] = { 0,0,0 };
	double xp = 0, yp = 0;
	int flag[3] = { 0,0,0 };

	while (cin >> x[0]>> y[0]>> x[1]>> y[1]>> x[2]>> y[2]>> xp>> yp) {
		for (int i = 0; i < 3; i++) {
			int temp1 = (i + 1) % 3;
			int temp2 = (i + 2) % 3;
			double checkI = (y[temp1] - y[i]) * (x[temp2] - x[i]) - (x[temp1] - x[i]) * (y[temp2] - y[i]);
			double checkP = (y[temp1] - y[i]) * (xp - x[i]) - (x[temp1] - x[i]) * (yp - y[i]);

			if (checkI * checkP > 0) {
				flag[i] = 1;
			}
		}
		if (flag[0] == 1 && flag[1] == 1 && flag[2] == 1) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
		flag[0] = 0;
		flag[1] = 0;
		flag[2] = 0;
	}
	*/
	/*
	int input_num;
	vector<int> train_num;
	while (cin >> input_num) {
		if (input_num == 0) {
			cout << train_num.back() << endl;
			train_num.pop_back();
		}
		else if (input_num >= 1 && input_num <= 10) {
			train_num.push_back(input_num);
		}
	}
	*/
	/*
	int d;
	int sum = 0;
	while (cin >> d) {
		for (int i = 0; i < 600 / d; i++) {
			sum += d*i*d*i*d;
		}
		cout << sum << endl;
		sum = 0;
	}
	*/
	/*
	int a[4], b[4];

	while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
		int hit = 0;
		int blow = 0;
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				if (a[i] == b[j]) {
					if (i == j) {
						hit++;
					}
					else {
						blow++;
					}
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
	*/

	int Month[13]{
		0,
		31,29,31,30,
		31,30,31,31,
		30,31,30,31
	};
	//??????0?????\???6
	int dow = 2;
	int in_day, in_month;
	while (cin >> in_month >> in_day) {

		if (in_month == 0)break;

		dow = 2;
		for (int i = 0; i < in_month; i++) {
			dow += Month[i];
		}
		dow += in_day;
		if (dow % 7 == 0) {
			cout << "Monday" << endl;
		}
		else if (dow % 7 == 1) {
			cout << "Tuesday" << endl;
		}
		else if (dow % 7 == 2) {
			cout << "Wednesday" << endl;
		}
		else if (dow % 7 == 3) {
			cout << "Thursday" << endl;
		}
		else if (dow % 7 == 4) {
			cout << "Friday" << endl;
		}
		else if (dow % 7 == 5) {
			cout << "Saturday" << endl;
		}
		else if (dow % 7 == 6) {
			cout << "Sunday" << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
	#include <cstdio>
	#include <cstdlib>
	#include <time.h>
	#include <math.h>
	#include <vector>
	#include <queue>
	#include <map>
	#include <set>
	#include <algorithm>
	#include <iterator>
	#include <sstream>
	#include <string>
	#include <bitset>
	using namespace std;
	#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
	#define rep(i, n) FOR(i, 0, n)
	#define FIN(V) cout<<V<<endl
	#define pb push_back
	#define INF (1 << 30)
	typedef pair<int, int> P;
	typedef long long ll;
	typedef priority_queue<int> pq;
	int StrToInt(string);
	string IntToStr(int);
	int dx[4] = {1, -1, 0, 0};
	int dy[4] = {0, 0, 1, -1};
	
	int main(void){
		int month[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
		int n, m;
		while(cin >> n >> m, n || m){
			int day = 0;
			rep(i, n-1)day += month[i];
			day += m;
			cout << day << endl;
			int yo = day % 7;
			if(yo == 1){
				FIN("Thursday");
			}else if(yo == 2){
				FIN("Friday");
			}else if(yo == 3){
				FIN("Saturday");
			}else if(yo == 4){
				FIN("Sunday");
			}else if(yo == 5){
				FIN("Monday");
			}else if(yo == 6){
				FIN("Tuesady");
			}else if(yo == 0){
				FIN("Wednesday");
			}
		}


		return 0;
	}
	
	
	
	int StrToInt(string s){
		stringstream ss;
		ss << s;
		int val;
		ss >> val;
		return val;
	}
	string IntToStr(int i){
		stringstream ss;
		ss << i;
		return ss.str();
	}

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

int main()
{
    string day[]={"Wednesday","Thirsday","Friday","Saturday","Sunday","Monday","Tuesday"};
    int Mon[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
    int m,d;
    while(cin>>m>>d,m*d){
        int allDay=d;
        for(;m>0;m--){
            allDay += Mon[m-1];
        }
        cout<<day[allDay%7]<<endl;
    }
}

C++: #include <iostream>

int day_count(int month, int day) {
    int per_month[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};    
    int total = 0;
    for (int i = 0; i < month - 1; i++) {
        total += per_month[i];
    }
    return total + day;
}

void day_check(int month, int day) {
    int count = day_count(month, day);
    count %= 7;
    std::string day_array[] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};
    std::cout << day_array[count] << std::endl;
    return; 
}

int main(void) {
    int month;
    int day;
    while (1) {
        std::cin >> month >> day;
        if (month == 0) {
            return 0;;
        }
        day_check(month, day);
    }
    return 0;
}

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

int main() {
	vector<int> r;
	string d[7]={"Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"};
	while (true)
	{
		int m,d;
		cin >> m >> d;
		if (m==0)break;
		r.push_back((6+(13*(m+1))/5+d)%7);
	}
	for (int i=0; i<r.size(); i++)
	{
		cout << d[r[i]] << endl;
	}
	return 0;
}

C++: #include <iostream>

int main()
{
    while (true) {
        int m, d;
        std::cin >> m >> d;
        if (m == 0) break;

        const char *weekdays[] = {
            "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"
        };
        const int total_days[] = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 };
        std::cout << weekdays[(total_days[m - 1] + d - 1) % 7] << std::endl;
    }
}

C++: #include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <cctype>
#include <iostream>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
int size(string x){
	string::size_type size=x.size();
	return size;
}
#define fu(l,k) for(int i=l;i<k;i++)
#define fd(l,k) for(int i=l;i>k;i--)
#define sort(ss) sort(ss.begin(), ss.end())
#define rsort(ss) sort(ss.rbegin(), ss.rend())
typedef  vector<string> vs;
typedef  vector<int> vi;
double pi(){
	return M_PI;
}
typedef set<int> set_i;
typedef set<string> set_s;
int INF=1000000;
int main(){
	int m,d,ans;
	string w[7]={"Monday","Tuesday","Wednesday",
	               "Thursday","Friday","Saturday","Sunday"};
	while(1){
		cin>>m>>d;
		if(m==0&&d==0) break;
		if(m==1||m==4||m==7){
			//start:Thursday
			ans=d%7;
			if(ans<3){
				cout<<w[3+ans-1]<<endl;
			}
			else{
				cout<<w[3-7+ans]<<endl;
			}
		}
		if(m==2||m==8){
			//start:Sunday
			ans=d%7;
			cout<<w[7-ans]<<endl;
		}
		if(m==3||m==11){
			//start:Monday
			ans=d%7;
			if(ans==0) cout<<w[6]<<endl;
			else cout<<w[7-ans]<<endl;
		}
		if(m==6){
			//start:Tuesday
			ans=d%7;
			if(ans<1){
				cout<<w[1+ans-1]<<endl;
			}
			else{
				cout<<w[1-7+ans]<<endl;
			}
		}
		if(m==10){
			//start:friday
			ans=d%7;
			if(ans<4){
				cout<<w[4+ans-1]<<endl;
			}
			else{
				cout<<w[4-7+ans]<<endl;
			}
		}
		if(m==5){
			//Saturday
			ans=d%7;
			if(ans<5){
				cout<<w[5+ans-1]<<endl;
			}
			else{
				cout<<w[5-7+ans]<<endl;
			}
		}
		if(m==9||m==12){
			//start:Wednesday
			ans=d%7;
			if(ans<2){
				cout<<w[2+ans-1]<<endl;
			}
			else{
				cout<<w[2-7+ans]<<endl;
			}
		}
	}
}