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 <cstdlib>
#include <string>
using namespace std;
const int year = 2004;

string getDay(int mm, int dd)
{
    int yy = year;
    int ans;
    if(mm <= 2)
    {
        yy -= 1;
        mm += 12;
    }
    ans = (
        dd + ((8+(13 * mm))/5)
        + (yy + (yy / 4) - (yy / 100))
        + (yy / 400)
    ) % 7;

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

int main()
{
    int mm, dd;
    while(1)
    {
        cin >> mm >> dd;
        if(mm == 0) break;
        cout << getDay(mm, dd) << endl;
    }

    return EXIT_SUCCESS;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int monthNum[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	string dayName[7] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};
	int month, day, passDay=0;
	
	while (1) {
		cin >> month; cin >> day;
		if (month == 0) break;
		
		for (int i=0; i<month; i++)
			passDay += monthNum[i];
		passDay += day-1;
		
		cout << dayName[passDay % 7] << endl;
	}
	
	return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
    for(;;){
	int m,d;
	int data[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	cin>>m>>d;
	if(m==0&&d==0)break;
	for(int i=1;i<=m;i++){
        d+=data[i-1];
	}
	switch(d%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;
    }




    }




	return 0;
}

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

int main()
{
	int month,day;
	int months[] = {31,29,31,30,31,30,31,31,30,31,30,31};
	string days[7] = {"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wndnessday"};
	while(cin >> month >> day)
	{
		if(month == 0) break;
		else
		{
			int sum = 0;
			for(int i=0;i<month-1;i++)
			{
				sum += months[i];
			}
			sum += day;
			cout << days[sum%7-1] << endl;
		}
	}
	return 0;
}

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

int main() {
  int days[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
  string youbi[7] = {"Monsay","Tuesday","Wednesday","Thursday",
		     "Friday","Saturday","Sunday"};
  while(1) {
    int mon, day;
    cin >> mon >> day;
    if(mon == 0) break;

    int sum = 0;
    for(int i = 0; i < mon-1; i++) {
      sum += days[i];
    }
    sum += day;

    cout << youbi[(sum+2)%7] << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
  int d[]={31,29,31,30,31,30,31,31,30,31,30,31};
  string s[]={"Thursday",
	      "Friday","Saturday","Sunday","Monday","Tuesday","Wednesday",};
  int i,j;
  int a,b;
  cin>>a>>b;
  while(a!=0){
    int o=0;
    for(i=1;i<a;i++) o+=d[i-1];
    o+=b-1;
    //cout << o << endl;
    cout << s[o%7] << endl;
    cin>>a>>b;
  }
  return 0;
}

C++: #include<stdio.h>
 
int main(){
	int m, d, h[11], i;
	h[0] = h[2] = h[4] = h[6] = h[7] = h[9] = 31;
	h[3] = h[5] = h[8] = h[10] = 30;
	h[1] = 29;
	while(scanf("%d %d", &m, &d) != 0){
		if(m == 0 || d == 0) break;
		for(i = 0; i < m - 1; i++) d += h[i];
		if(d % 7 == 1) printf("Thursday\n");
		else if(d % 7 == 2) printf("Friday\n");
		else if(d % 7 == 3) printf("Saturday\n");
		else if(d % 7 == 4) printf("Sunday\n");
		else if(d % 7 == 5) printf("Monday\n");
		else if(d % 7 == 6) printf("Tuesday\n");
		else if(d % 7 == 0) printf("Wednesday\n");
	}
	return 0;
}

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

using namespace std;

int Month;
int Day;

const char *data[7] ={
 "Monday",
 "Tuesday",
 "Wednesday",
 "Thursday",
 "Friday"
 "Saturday",
 "Sunday"
};
const int days[12] = {31,29,31,30,31,30,31,31,30,31,30,31};

int ans[12][31];
int main(int argc, char *argv[])
{
  while(scanf("%d %d",&Month,&Day)){
      int d = 3;
    if(Month == 0)
      break;
    for(int i = 0;i < 12;i++){
      for(int j = 0;j < days[i];j++){
	ans[i][j] = d%7;
	d++;
      }
    }
    cout <<data[ans[Month-1][Day-1]]<<endl;
  }
  return 0;
}

C++: #include <stdio.h>
int main(){
    int tuki,hi,youbi=4;
    while(1){
        scanf("%d %d",&tuki,&hi);
        if(tuki==0) break;
        switch(tuki){
            case 2: youbi=youbi+31+hi-1;
                break;
            case 3: youbi=youbi+60+hi-1;
                break;
            case 4: youbi=youbi+91+hi-1;
                break;
            case 5: youbi=youbi+121+hi-1;
                break;
            case 6: youbi=youbi+152+hi-1;
                break;
            case 7: youbi=youbi+182+hi-1;
                break;
            case 8: youbi=youbi+213+hi-1;
                break;
            case 9: youbi=youbi+244+hi-1;
                break;
            case 10: youbi=youbi+274+hi-1;
                break;
            case 11: youbi=youbi+305+hi-1;
                break;
            case 12: youbi=youbi+335+hi-1;
                break;
        }
        youbi=youbi%7;
        switch(youbi){
            case 0:puts("Sunday");
                break;
            case 1:puts("Monday");
                break;
            case 2:puts("Tuesday");
                break;
            case 3:puts("Wednesday");
                break;
            case 4:puts("Thursday");
                break;
            case 5:puts("Friday");
                break;
            case 6:puts("Saturday");
                break;
        }
        youbi=4;
    }
    return 0;
}

C++: #include <iostream>

int main(){
    int m, d, w = 3;
    int days[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    char *weekName[7] = {"Sunday", "Monday", "Tuesday", "Wednesday",
                         "Thursday", "Friday", "Saturday"};
    while(1){
        std::cin >> m >> d;
        if(!(m || d)){
            return 0;
        }
        for(int i = 1; i < m; i++){
            w += days[i - 1];
        }
        w += d; 
        std::cout << weekName[w % 7] << std::endl;
    }
}