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 <stdio.h>
#include <string.h>
#include <time.h>

int
main(void)
{
	char line[80];

	int m, d;
	
	while (true) {
		if (fgets(line, sizeof line, stdin) == NULL) {
			return 0;
		}
		if (sscanf(line, "%d %d", &m, &d) != 2) {
			return 0;
		}

		if (m == 0) {
			return 0;
		}
		
		struct tm tm0;
		memset(&tm0, 0, sizeof tm0);
		
		tm0.tm_year = 2004-1900;
		tm0.tm_mon = m - 1;
		tm0.tm_mday = d;

		time_t t = mktime(&tm0);
		
		struct tm* tm1 =localtime(&t);
		
		strftime(line, sizeof line, "%A", tm1);

		printf("%s\n", line);
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int m,d,h,y=4;
char w[][7]={"Satur","Sun","Mon","Tues","Wednes","Thurs","Fri"};
for(;;){
cin>>m>>d;
if(m==0)break;
if(m<3){m+=12;y--;}
h=(y+int(y/4)+int(20/4)-2*20+int(13*(m+1)/5)+d)%7;
cout<<w[h]<<"day"<<endl;
}
return 0;
}

C++: #include <stdio.h>
int main(){
    int a[12]={3,1,3,2,3,2,3,3,2,3,2,3},n,m;
    while(1){
        scanf("%d%d",&n,&m);
        if(n==0)return 0;
        
        for(int i=0;i<n-1;i++){
            m+=a[i];
        }
        m+=3;
        m%=7;
        switch(m){
            case 1:
                printf("Monday\n");
                break;
            case 2:
                printf("Tuesday\n");
                break;
            case 3:
                printf("Wednesday\n");
                break;
            case 4:
                printf("Thursday\n");
                break;
            case 5:
                printf("Friday\n");
                break;
            case 6:
                printf("Saturday\n");
                break;
            case 0:
                printf("Sunday\n");
                break;
        }
    }
    
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int day_month[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
char day[10][10]={
  {"Thursday"},
  {"Friday"},
  {"Saturday"},
  {"Sunday"},
  {"Monday"},
  {"Tuesday"},
  {"Wednesday"},
};
int main(){
  int m,d,count;
  while(1){
    cin >> m >> d;
    if(!m && !d)break;
    count = -1;
    for(int i=1;i<=m;i++){
      if(i == m){
	for(int j=1;j<=d;j++){
	  count++;
	}
      }else {
	for(int j=1;j<=day_month[i];j++){
	  count++;
	}
      }
    }
    cout << day[count % 7] << endl;
  }
}

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

int main()
{
	int month[] = {
		0, 31, 29, 31, 30, 31, 30,
		31, 31, 30, 31, 30, 31
	};
	int m, d;
	while(cin >> m >> d){
		if(m == 0) break;
		int days = 0;
		for(int i = 1; i < m; i++) days += month[i];
		days += d;
		days = days % 7;
		switch(days){
		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<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<iomanip>
 
#define EPS (1e-10)
using namespace std;
#define PI (3.1415926535)

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

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

	int m, d;
	while(cin >> m >> d){
		if(m == 0 && d == 0){
			break;
		}
		for(int i = 1; i < m; i++){
			d += month[i];
		}

		cout << day[d%7] << endl;
	}

	return 0;
}

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

int main()
{
  int m,d;
  string week[7] = {"Thursday", "Friday", "Saturday", "Sunday","Mondy", "Tuesday", "Wednesday"};
  int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  
  while (scanf("%d %d", &m, &d)) {
    if (m+d == 0) { break; };
    int day = 0;
    for (int i = 0; i < (m - 1); i++) {
      day += month[i];
    }
    day += d;
    cout << week[(day%7)-1] << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;


int date[12][31];
string day[7] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};

int main() 
{
    for(int i = 0; i < 12; i++){
        for(int j = 0; j < 31; j++){
            date[i][j] = 0;
        }
    }
    for(int i = 0; i < 12; i++){
        if(i == 3 || i == 5 || i == 8 || i == 10){
            for(int j = 0; j < 30; j++){
                date[i][j] = 1;
            }
        }else if(i == 1){
            for(int j = 0; j < 29; j++){
                date[i][j] = 1;
            }
        }else{
            for(int j = 0; j < 31; j++){
                date[i][j] = 1;
            }
        }
    }
    while(true){
        int cnt = 0;
        int m,d;
        cin >> m >> d;
        if(m==0 && d == 0) break;
        m--; d--;
        for(int i = 0; i < 12; i++){
            for(int j = 0; j < 31; j++){
                if((i < m || (i == m && j <= d)) && date[i][j] == 1){
                    cnt++;
                }
            }
        }
        cnt += 2;
        cout << day[cnt%7] << endl;
    }
}

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,a+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>
using namespace std;
int subZeller(int m,int d){
	int y=2004;
	if(m<3){
		y--;
		m+=12;
	}
	return(y+y/4-y/100+y/400+(13*m+8)/5+d)%7;
}

int main(){
	
	int month,day;
	char *dayname[]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
	while(cin>>month>>day){
		if(month!=0&&day!=0){
			cout<<dayname[subZeller(month,day)]<<endl;
		}
		else
			break;
	}
}