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 <cstdio>
using namespace std;

int main()
{
	int month, day;
	int monthday[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	
	while(scanf("%d %d", &month, &day)!= EOF)
	{
		if(month == 0) break;
		for(int i = 0; i < month;i++)
		{
			day = day + monthday[i];
	}
		day = day % 7;
		
		switch(day){
		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++: #define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int vec[12]={31,29,31,30,31,30,31,31,30,31,30,31};
  int m,d,c;
  while(cin>>m>>d){
    if(m==0) break;
    c=0;
    if(m!=1) rep(i,m-1) c+=vec[i];
    c+=d;
    if(c%7==1) cout<<"Thursday"<<endl;
    else if(c%7==2) cout<<"Friday"<<endl;
    else if(c%7==3) cout<<"Saturday"<<endl;
    else if(c%7==4) cout<<"Sunday"<<endl;
    else if(c%7==5) cout<<"Monday"<<endl;
    else if(c%7==6) cout<<"Tuesday"<<endl;
    else if(c%7==0) cout<<"Wednesday"<<endl;
  }
      
  return 0;
}

C++: #include <stdio.h>

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

int main()
{
	int mon,day;
	int ans;
	scanf("%d %d",&mon,&day);
	while(mon != 0 || day != 0){
		ans = 0;
		for(int i = 0; i < mon - 1; i++){
			ans += month[i];
		}
		ans += day;
		ans = ans % 7;
		if(ans == 1){
			printf("Thursday\n");
		}
		if(ans == 2){
			printf("Friday\n");
		}
		if(ans == 3){
			printf("Saturday\n");
		}
		if(ans == 4){
			printf("Sunday\n");
		}
		if(ans == 5){
			printf("Monday\n");
		}
		if(ans == 6){
			printf("Tuesday\n");
		}
		if(ans == 0){
			printf("Wednesday\n");
		}
		scanf("%d %d",&mon,&day);

	}
	return 0;
}

C++: #include <fstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

int main() {
  int year[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
  string day[7] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
  int first = 3;

  int m, d;
  while (true) {
    cin >> m >> d;
    if (!(m|d)) break;
    int n = first;
    for (int i = 0; i < m-1; i++) {
      n += year[i];
    }
    n += d-1;

    n %= 7;
    cout << day[n] << endl;
  }
}

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

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

int main(){
	while(cin >> m >> d){
		if(m == 0) break;

		for(int i = 0; i < m - 1; i++){
			d+=data[m];
		}
		cout << day[(d-1)%7] << endl;
	}
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)

const int month[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30};
int main()
{
  int m, d, cntdays = 0;
  
  while (cin >> m >> d, m + d){
    cntdays = month[m - 1] + d;
    switch (cntdats % 7){
      case 1:
        cout << "Monday";
        break;
      case 2:
        cout << "Tuesday";
        break;
      case 3:
        cout << "Wednesday";
        break;
      case 4:
        cout << "Thursday";
        break;
      case 5:
        cout << "Friday";
        break;
      case 6:
        cout << "Saturday";
        break;
      case 0:
        cout << "Sunday";
        break;
      cout << endl;
    }
  }
}

C++: #include <iostream>

using namespace std;


int main()
{
    int m[50],d[50];
    int x = 0;
    string Day[7] = {"Thursday", "Friday","Saturday","Sunday","Monday", "Tuesday", "Wednesday"};
    int BanyakHari[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
    int DayinBetween = 0;
    string ThatDayIs[50];

    do
    {
        cin >> m[x] >> d[x];
        if((m[x] == 0) && (d[x] == 0))
        {
            break;
        }
        //Check banyak hari antara 1 Januari - Input
        for(int y = 0; y < m[x]-1; y++)
        {
            DayinBetween = DayinBetween + BanyakHari[y];
        }
        DayinBetween = DayinBetween + d[x] - 1;

        //Kurangi sampai < 7
        while(true)
        {
            if(DayinBetween >= 7)
            {
                DayinBetween = DayinBetween - 7;
            }
            else
            {
                break;
            }
        }

        ThatDayIs[x] = Day[DayinBetween];

        x++;
    }
    while(x < 50);

    for(int z = 0; z < x; z++)
    {
        cout << ThatDayIs[z] << endl;
    }


}

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

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

int from_1_1(int m, int d) 
{
    int day_from_1_1 = d;
    for (int i = 0; i < m; i++) {
        day_from_1_1 += days[i];
    }
    return day_from_1_1;
}

int main(void)
{
    int m, d;
    string day;
    while (cin >> m >> d) {
        if (m == 0 && d == 0) break;
        switch ( from_1_1(m, d) % 7 ) {
            case 1:
                day = "Thursday";
                break;
            case 2:
                day = "Friday";
                break;
            case 3:
                day = "Saturday";
                break;
            case 4:
                day = "Sunday";
                break;
            case 5:
                day = "Monday";
                break;
            case 6:
                day = "Tuesday";
                break;
            case 0:
                day = "Wednesday";
                break;
            default: // DO_NOTHING
                break;
        }
        cout << day << endl;
    }
    return 0;
}