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

int main(){
  int m,d,x,i;

  while(1){
    cin>>m>>d;
    if(m==0&&d==0)break;
    x=0;
    for(i=1;i<m;i++){
      switch(i){
      case 1:
      case 3:
      case 5:
      case 7:
      case 8:
      case 10:
      case 12:
	x+=3;
	break;      
      case 2:
	x+=1;
	break;
      default:
	x+=2;
      }
    }
  switch((x+d-1)%7){
      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;
  }
  }  
  return 0;
}

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

using namespace std;

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

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

        int year = 2004, h;
        if (m == 1 || m == 2) {
            year--;
            m += 12;
        }
        h = (year + year / 4 - year / 100 + year / 400 + (13 * m + 8) / 5 + d) % 7;
        
        cout << day[h] << endl;
    }

    return 0;
}

C++: #include<cstdio>

int day_date[12]={3,6,0,3,5,1,3,6,2,4,0,2};
int mon;
int day;

int main()
{
	while(true)
	{
		scanf("%d%d",&mon,&day);
		if(mon==0)break;
		int date=(day+day_date[mon-1]-1)%7;
		if(date==0) printf("Monday");
		if(date==1) printf("Tuesday");
		if(date==2) printf("Wednesday");
		if(date==3) printf("Thursday");
		if(date==4) printf("Friday");
		if(date==5) printf("Saturday");
		if(date==6) printf("Sunday");
		printf("\n");
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int a[13][32];
void day(void)
{
    int check=3;
    for(int i=1;i<13;i++){
        for(int j=1;j<32;j++){
            a[i][j]=check;
            check++;
            if(check==7)check=0;
            if((i==4||i==6||i==9||i==11)&&j==30)break;
            else if(i==2&&j==29)break;
        }
    }
}
int main()
{
    int mon,date;
    day();
    while(1){
        cin>>mon>>date;
        if(mon==0&&date==0)break;
        if(a[mon][date]==0)cout<<"Monday\n";
        else if(a[mon][date]==1)cout<<"Tuesday\n";
        else if(a[mon][date]==2)cout<<"Wednesday\n";
        else if(a[mon][date]==3)cout<<"Thrusday\n";
        else if(a[mon][date]==4)cout<<"Friday\n";
        else if(a[mon][date]==5)cout<<"Saturday\n";
        else cout<<"Sunday\n";
    }

}

C++: //1=31,2=29,3=31,4=30,5=31,6=30,7=31,8=31,9=30,10=31,11=30,12=31//
#include <iostream>
#include<string>
using namespace std;
int main(){
    string str[7]{"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
    int t[11]{31,60,91,121,152,182,213,244,274,305,335};
    //        0   1  2  3   4   5   6  7    8   9   10//
    int d,m;
    while(cin>>m>>d){
        if(m==0)break;
        if(m==1)cout<<str[d%7]<<endl;
        else{
            d=d+t[m-2];
            cout<<str[d%7]<<endl;
        }
    }
    return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int data[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	string out[7]={
	"Wednesday",
	"Thursday",
	"Friday",
	"Saturday",
	"Sunday",
	"Monday",
	"Tuesday"
	};
	int a,b;
	while(cin>>a>>b,a+b){
		int sum=b;
		rep(i,a-1)sum+=data[i];
		cout<<out[sum%7]<<endl;
	}
}

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

int day(int m, int d){
	if(m==1)return d;
	if(m==2)return 31+d;
	if(m==3)return 60+d;
	if(m==4)return 91+d;
	if(m==5)return 121+d;
	if(m==6)return 152+d;
	if(m==7)return 182+d;
	if(m==8)return 213+d;
	if(m==9)return 244+d;
	if(m==10)return 274+d;
	if(m==11)return 304+d;
	if(m==12)return 366-d;
}

int main(){
	while(1){
		int m,d;
		std::cin>>m>>d;
		if(m==0)return 0;
		std::string s;
		if(day(m,d)%7==1)s="Thursday";
		if(day(m,d)%7==2)s="Friday";
		if(day(m,d)%7==3)s="Saturday";
		if(day(m,d)%7==4)s="Sunday";
		if(day(m,d)%7==5)s="Monday";
		if(day(m,d)%7==6)s="Tuesday";
		if(day(m,d)%7==0)s="Wednesday";
		std::cout<<s<<std::endl;
	}
}

C++: #include <iostream>
using namespace std;
int main(void)
{
  int m, d;
  
  while(1) {
    cin >> m >> d;
    if(m == 0) break;
    
    for(int i = m ; i > 1 ; i--) {
      if(i-1 == 4 || i-1 == 6 || i-1 == 9 || i-1 == 11) d += 30;
      else if(i-1 == 2) d += 29;
      else if(i-1 == 1 || i-1 == 3 || i-1 == 5 || i-1 == 7 || i-1 == 8 || i-1 == 10) d += 31;
    }
    
    if(d % 7 == 1) cout << "Thursday" << endl;
    if(d % 7 == 2) cout << "Friday" << endl;
    if(d % 7 == 3) cout << "Saturday" << endl;
    if(d % 7 == 4) cout << "Sunday" << endl;
    if(d % 7 == 5) cout << "Monday" << endl;
    if(d % 7 == 6) cout << "Tuesday" << endl;
    if(d % 7 == 0) cout << "Wednesday" << endl;
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int m,d;
	while(cin >> m >> d,m){
		int sum = 0;
		for(int i = 1; i < m; i++){
			switch(i){
				case 1:
				case 3:
				case 5:
				case 7:
				case 8:
				case 10:
					sum += 31;
					break;
				case 4:
				case 6:
				case 9:
				case 11:
					sum += 30;
					break;
				case 2:
					sum += 29;
					break;
				default:
					break;
			}
		}
		sum += d;
		switch(sum%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;
		}
	}
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)

const int month[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30};
int main()
{
  int m, d, cntdays = 0;
  
  while (cin >> m >> d, m){
    cntdays = month[m - 1] + d;
    switch (cntdays % 7){
      case 5:
        cout << "Monday";
        break;
      case 6:
        cout << "Tuesday";
        break;
      case 0:
        cout << "Wednesday";
        break;
      case 1:
        cout << "Thursday";
        break;
      case 2:
        cout << "Friday";
        break;
      case 3:
        cout << "Saturday";
        break;
      case 4:
        cout << "Sunday";
        break;
    }
    cout << endl;
  }
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

int main(){
	int m,d;
	const int day[] = {31,29,31,30,31,30,31,31,30,31,30,31};
	const char *youbi[] = {
		"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
	};
	while(scanf("%d",&m),m){
		scanf("%d",&d);
		int sum = 0;
		rep(i,m-1)sum+=day[i];
		sum += d;
		puts(youbi[(sum+2)%7]);
	}
	return 0;
}