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 <iostream>
#include <string>
using namespace std;

int month[] = {31,29,31,30,31,31,30,31,31,30,31,30,31};
string date[] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};

int main(){
	int M, D;
	while( cin >> M >> D, M ){
		int d = 3;
		for(int i=0; i<M-1; i++ ){
			d += month[i];
		}
		d += D;
		d %= 7;
		cout << date[d] << endl;
	}
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main()
{
  int calen[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
  int month,day;
  int ans = 0;

  while(cin >> month >> day){
    if(month == 0)break;
    
    ans = 0;

    for(int i = 0;i < month-1;i++){
      ans += calen[i];
    }

    ans += day;
    cout << ans << endl;

    switch (ans % 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;
    }

  }
}

C++: #include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>
#include<array>

using namespace std;

int main()
{
  array<int,13> ma = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

  int m, d, yd;

  while ( cin >> m >> d && ( m != 0 || d != 0 ))
    {
      yd = 0;
      for ( int i = 1; i < m; ++i )
        yd += ma[i];
      yd += d;

      int wd = yd % 7;

      switch ( wd )
        {
        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 <stdio.h>
  int main(){
int i,j;
int x[12]={0,31,60,91,121,152,182,213,243,274,304,335};
int n,m;
while(1){
scanf("%d%d",&n,&m);
if(n==0){
break;
}
int q=(x[n-1]+m)%7;
if(q==0){
printf("Wednesday\n");
}else if(q==1){
printf("Thursday\n");
}else if(q==2){
printf("Friday\n");
}else if(q==3){
printf("Saturday\n");
}else if(q==4){
printf("Sunday\n");
}else if(q==5){
printf("Monday\n");
}else if(q==6){
printf("Tuesday\n");
}
}
return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <algorithm>

using namespace std;

int dayNum[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string day[7] = { "Monday",
				  "Tuesday",
				  "Wednesday",
				  "Thursday",	// <- 2004/1/1
				  "Friday",
				  "Saturday",
				  "Sunday" };

int main() {
	int m, d;
	
	cin >> m >> d;
	
	while (m != 0 && d != 0) {
		int daySum = 0;
		
		for (int i = 0; i < m - 1; i++) {
			daySum += dayNum[i];
		}
		
		daySum += d;
		
		cout << day[ daySum % 7 + 2 ] << endl;
		
		cin >> m >> d;
	}
	
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
  int month,day,bell;
  string s;
  while(1){
    cin >> month >> day;
    if(month==0 && day==0){
      break;
    }
    if(month==1 || month==4 || month==7){
      bell=4;
    }
    else if(month==2 || month==8){
      bell=7;
    }
    else if(month==3 || month==11){
      bell=1;
    }
    else if(month==5){
      bell=6;
    }
    else if(month==6){
      bell=2;
    }
    else if(month==9 || month==12){
      bell=3;
    }
    else if(month==10){
      bell=5;
    }

    for(int i=1;i<day;i++){
      bell++;
      if(bell>=8){
	bell=1;
      }
    }

    if(bell==1){
      s="Monday";
    }
    else if(bell==2){
      s="Tuesday";
    }
    else if(bell==3){
      s="Wednesday";
    }
    else if(bell==4){
      s="Thursday";
    }
    else if(bell==5){
      s="Friday";
    }
    else if(bell==6){
      s="Saturday";
    }
    else if(bell==7){
      s="Sunday";
    }
    cout << s << endl;
  }
  return (0);
}

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

int main() {
	int month, day; cin >> month >> day;
	while (month != 0 && day != 0) {
		if (month >= 1) day = day;
		if (month >= 2) day = day + 31;
		if (month >= 3) day = day + 29;
		if (month >= 4) day = day + 31;
		if (month >= 5) day = day + 30;
		if (month >= 6) day = day + 31;
		if (month >= 7) day = day + 30;
		if (month >= 8) day = day + 31;
		if (month >= 9) day = day + 31;
		if (month >= 10) day = day + 30;
		if (month >= 11) day = day + 31;
		if (month >= 12) day = day + 30;
		if (day % 7 == 0) cout << "Wednesday" << endl;
		if (day % 7 == 1) cout << "Thursday" << endl;
		if (day % 7 == 2) cout << "Friday" << endl;
		if (day % 7 == 3) cout << "Saturday" << endl;
		if (day % 7 == 4) cout << "Sunday" << endl;
		if (day % 7 == 5) cout << "Monday" << endl;
		if (day % 7 == 6) cout << "Tuesday" << endl;
		cin >> month >> day;
	}
	return 0;
}

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

string weekday(int n){
	switch(n){
	case 0:	return "Monday";
	case 1: return "Tuesday";
	case 2: return "Wednesday";
	case 3: return "Thursday";
	case 4: return "Friday";
	case 5: return "Saturday";
	case 6: return "Sunday";
	}
}

int monthdays(int m){
	switch (m){
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			return 31;
		case 4:
		case 6:
		case 9:
		case 11:
			return 30;
		case 2:
			return 29;
	}
	return 0;
}

int days(int m, int d){
	int s=0;
	for (int i=1; i<m; i++)
		s += monthdays(i);
	return s+d;
}

int main(void){
	
	while (true){
		int m,d;
		cin>>m>>d;
		if (m==0) break;
		int dif = days(m, d)-1;
		cout<<weekday((dif+3)%7)<<endl;
	}
	return 0;
}