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>
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 == 4 || 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 == 7) cout << "Wednesday" << endl;
  }
  return 0;
}

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

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int m, d;
	while(cin >> m >> d && m != 0){

		for(int i = 0; i < m - 1; ++i){
			d += day[i];
		}

		d -= 1;
		cout << data[d % 7 + 3] << endl;
	}

	return 0;
}

C++: #include<cstdio>
#include<iostream>
using namespace std;
main(){
  int m,d;
  while(1){
    cin >> m >> d;
    if(m==0){
      exit(0);
    }
    if(m>2){
      d=d-2;
      if(m>4){
	d--;
	if(m>6){
	  d--;
	  if(m>9){
	    d--;
	    if(m>11){
	      d--;
	    }
	  }
	}
      }
    }
    m--;
    d=(d+m*31)%7;
    if(d==0){
      cout <<"Wednesday"<< endl;
    }
    else if(d==1){
      cout <<"Thursday"<< endl;
    }
    else if(d==2){
      cout <<"Friday"<< endl;
    }
    else if(d==3){
      cout <<"Saturday"<< endl;
    }
    else if(d==4){
      cout <<"Sunday"<< endl;
    }
    else if(d==5){
      cout <<"Monday"<< endl;
    }
    else if(d==6){
      cout <<"Tuesday"<< endl;
    }
  }
}

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

int main(){
	int month[13]={0,31,29,31,30,31,30,31,31,30,31,30,31},m,d,sum=0;
	string str[7]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
	while(cin>>m>>d,m+d){
		sum=0;
		for(int i=1;i<m;i++){
			sum+=month[i];
		}
	sum+=d;
	cout<<str[sum%=7]<<endl;;
	}
}

C++: #define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
	int m, d;
	for (; cin >> m >> d;)
	{
		if (m == 0 && d == 0)
		{
			break;
		}

		vector<int> mon = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

		int y = (3 + mon.at(m - 1) + d) % 7;

		vector<string> sy = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

		cout << sy.at(y) << endl;
	}
}

C++: #include<stdio.h>

char *str[7] = {"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
int tuki[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};

int main(){
	int a,b;
	int i,d;
	
	while( scanf("%d%d",&a,&b) ){
		if( a == 0 )break;
		d = 0;
		
		for( i = 0;i < a;i++ ){
			d += tuki[i];
		}
		d += b-1;
		
		printf("%s\n",str[ d%7 ] );
	}
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main() {
	int a, b,h,  kazu;
	int  ans[1000];
	kazu = 0;
	while (1) {
		cin >> a >> b;
		if (a == 0) {
			goto a;
		}
		h = 0;
		kazu = kazu + 1;
		if (a >= 2) {
			h = 31;
		}
		if (a >= 3) {
			h = h + 29;
		}
		if (a >= 4) {
			h = h + 31;
		}
		if (a >= 5) {
			h = h + 30;
		}
		if (a >= 6) {
			h = h + 31;
		}
		if (a >= 7) {
			h = h + 30;
		}
		if (a >= 8) {
			h = h + 31;
		}
		if (a >= 9) {
			h = h + 31;
		}
		if (a >= 10) {
			h = h + 30;
		}
		if (a >= 11) {
			h = h + 31;
		}
		if (a >= 12) {
			h = h + 30;
		}
		h = h + b;
		while (h > 7) {
			h = h % 7;
		}
		ans[kazu] = h;
		
	}
a:;
	for (int x = 1; x <= kazu; x++) {
		if (ans[x] == 0) {
			cout << "Wednesday" << endl;
		}
			if (ans[x] == 1) {
				cout << "Thursday" << endl;
			}
		if (ans[x] == 2) {
			cout << "Friday" << endl;
		}
		if (ans[x] == 3) {
			cout << "Saturday" << endl;
		}
		if (ans[x] == 4) {
			cout << "Sunday" << endl;
		}
		if (ans[x] == 5) {
			cout << "Monday" << endl;
		}
		if (ans[x] == 6) {
			cout << "Tuesday" << endl;
		}
	}
}

C++: #include <stdio.h>

int days[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30};
char weeks[7][10] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

int main(){

  int i;
  for(i=1;i<12;i++) days[i] += days[i-1];

  int m,d;
  while(1){
    scanf("%d%d", &m, &d);
    if(m==0) break;
    
    d += days[m-1]+3;
    d %= 7;

    printf("%s\n", weeks[d]);
  }
}

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

int month_day[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main(){
    int m, d;
    int day;

    while(1){
        day = 0;
        cin >> m >> d;
        if(m == 0 && d == 0) break;

        for(int i=1; i<m; i++){
            day += month_day[i-1];
        }
        day += d;

        switch(day % 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 <iostream>
#include <algorithm>
using namespace std;
int main(){
	int a,b,c;
	while(cin>>a>>b){
		if(a==0)break;
		if(a==1)c=b;
		if(a==2)c=31+b;
		if(a==3)c=60+b;
		if(a==4)c=91+b;
		if(a==5)c=121+b;
		if(a==6)c=152+b;
		if(a==7)c=182+b;
		if(a==8)c=213+b;
		if(a==9)c=244+b;
		if(a==10)c=274+b;
		if(a==11)c=305+b;
		if(a==12)c=335+b;
		if(c%7==1)cout<<"Thursday"<<endl;
		if(c%7==2)cout<<"Friday"<<endl;
		if(c%7==3)cout<<"Saturday"<<endl;
		if(c%7==4)cout<<"Sunday"<<endl;
		if(c%7==5)cout<<"Monday"<<endl;
		if(c%7==6)cout<<"Tuesday"<<endl;
		if(c%7==0)cout<<"Wednesday"<<endl;
	}
    return 0;
    }