Go: package main

import (
        "fmt"
)

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

        for {
                var m, d int
                _, err := fmt.Scanf("%d %d", &m, &d)
                if err != nil || m + d == 0 {
                        break
                }
                var days int

                for {
                        lm, ld := getLastDay(m, d)
                        if lm + ld == 0 {
                                break
                        }
                        days++
                        m = lm
                        d = ld
                }
                fmt.Println(weeks[days%7])
        }
}

func getLastDay(m int, d int) (lm int, ld int) {
        if m == 1 && d == 1 {
                return 0, 0
        }

        if d > 1 {
                return m, d-1
        } else {
                if m == 3 {
                        return m-1, 29
                }
                if m == 3 || m == 5 || m == 7 || m == 10 || m == 12 {
                        return m-1, 30
                } else {
                        return m-1, 31
                }
        }
}

C++: #include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#define PI 3.1415926535897932384626433
using namespace std;
int main(){
    int days[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
    int rui[13]={0};
    for(int i=1;i<=12;i++)rui[i]=rui[i-1]+days[i];
    while(1){
        int a,b;
        cin>>a>>b;
        if(a==0&&b==0)break;
        int p=rui[a-1]+b;
        if(p%7==0)cout<<"Wednesday"<<endl;
        if(p%7==1)cout<<"Thursday"<<endl;
        if(p%7==2)cout<<"Friday"<<endl;
        if(p%7==3)cout<<"Saturday"<<endl;
        if(p%7==4)cout<<"Sunday"<<endl;
        if(p%7==5)cout<<"Monday"<<endl;
        if(p%7==6)cout<<"Tuesday"<<endl;
    }
    return 0;
}

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

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int const MOD = 1000000007;

int dayOfTheWeek( int y, int m, int d )
{
    if( m < 3 ) {
        y--; m += 12;
    }
    return ( y + y/4 - y/100 + y/400 + ( 13*m + 8 )/5 + d )%7;
}

int main() {
    string dayname[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
    int m,d;
    while(cin >> m, m) {
        cin >> d;
        cout << dayname[dayOfTheWeek(2004,m,d)] << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
	int days[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	string youbi[7]={"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
	while(1){
		int m,d,s=0;
		cin >> m >> d;
		if(!m&&!d)	break;
		for(int i=0;i<m-1;i++)	s+=days[i];
		s+=d;
		cout << youbi[(s-1)%7] << endl;
	}
	return 0;
}

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

using namespace std;

string today(int month, int day){
    string today;
    int startMonth=1, startDay=1, total=0;
    
    for(int i=startMonth; i<month; i++){
        switch(i){
            case 4:
            case 6:
            case 9:
            case 11:
                total += 30;
                break;
            
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                total += 31;
                break;
            case 2:
                total += 29;
                break;
        }
    }
    total += day;
    //cout << total%7 << endl;
    
    switch(total%7){
        case 1:
            today = "Thursday";
            break;
        case 2:
            today = "Friday";
            break;
        case 3:
            today = "Saturday";
            break;
        case 4:
            today = "Sunday";
            break;
        case 5:
            today = "Mondday";
            break;
        case 6:
            today = "Tuesday";
            break;
        case 0:
            today = "Wednesday";
            break;
    }
    
    
    return today;
}


int main (int argc, char const* argv[]){
    int month, day, n;
    
    cin >> month >> day;
    while(month!=0 && day!=0){
        
        cout << today(month,day)<< endl;
        cin >> month >> day;
    }
    return 0;
}

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

int main(){
  vector<int> days = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  vector<string> week = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

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

    int ans = d;
    for(int i=0; i<m-1; i++) ans += days[i];
    
    cout << week[(ans + 2) % 7] << endl;
  }
}

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

int main(){
	int m,d;
	int mm[]={31,29,31,30,31,30,31,31,31,31,30,31};
	string s[]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	while(cin>>m>>d){
		if(m==0)break;
		int dd=0;
		for(int i=0;i<m-1;i++)dd+=mm[i];
		dd+=d;
		int ans=(dd+2)%7;
		//cout<<dd<<endl;
		cout<<s[ans]<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int zeller(int y, int m, int d) {
  if (m == 1 || m == 2) y--, m += 12;
  return (y + y / 4 - y / 100 + y / 400 + (13 * m + 8) / 5 + d) % 7;
}

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int m, d;
  while (cin >> m >> d, m) {
    cout << s[zeller(2004, m, d)] << endl;
  }

  return 0;
}

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

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

int mtod(int m){
	if (m==0)return 0;
	int re=0;
	if(m==2)re=29;
	else if(m==4 || m==6||m==9||m==11)re=30;
	else re=31;
	return mtod(m-1)+re;
}
int main(){
	int m,d;
	while(cin>>m>>d && m+d){
		int now=mtod(m-1)+d;
		cout<<day[(now-1)%7]<<endl;
	}
}

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