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() {
	int mth[12]={31,29,30,30,31,30,31,31,30,31,30,31};
	char wks[][16]={"Wedneday","Thursday","Friday","Suturdat","Sunday",
				"Monday","Tuesday"};
	int m,d;
	while(cin>>m>>d,m){
		int days=0;
		for(int i=0;i<m-1;i++) days+=mth[i];
		days+=d; cout<<wks[days%7]<<endl;
	}
	return 0;
}

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 (cntdays % 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,d,days=0;
	for(;;){
		cin>>m>>d;
		if(m==0){return 0;}
		switch(m){
			case 2:
		days=31;break;
			case 3:
		days=60;break;
			case 4:
		days=91;break;
			case 5:
		days=121;break;
			case 6:
		days=152;break;
			case 7:
		days=182;break;
			case 8:
		days=213;break;
			case 9:
		days=244;break;
			case 10:
		days=274;break;
			case 11:
		days=305;break;
			case 12:
		days=335;break;
		}
		days+=d;
		days=days%7;
		if(days==0)cout<<"Wednesday"<<endl;
		if(days==1)cout<<"Thursday"<<endl;
		if(days==2)cout<<"Friday"<<endl;
		if(days==3)cout<<"Saturday"<<endl;
		if(days==4)cout<<"Sunday"<<endl;
		if(days==5)cout<<"Monday"<<endl;
		if(days==6)cout<<"Tuesday"<<endl;
	}
}

C++: #include <stdio.h>

int main(void){
    int m,d,ds=0,i;
    while(scanf("%d %d",&m,&d)!=EOF){
        if(m==0) break;
        for(i=1;i<m;i++){
            if(i==2){
                ds+=29;
            }
            else if(i==4||i==6||i==9||i==11){
                ds+=30;
            }
            else{
                ds+=31;
            }
        }
        ds+=d-1;
        if(ds%7==5){
            printf("Monday\n");
        }
        else if(ds%7==6){
            printf("Tuesday\n");
        }
        else if(ds%7==0){
            printf("Wednesday\n");
        }
        else if(ds%7==1){
            printf("Thursday\n");
        }
        else if(ds%7==2){
            printf("Friday\n");
        }
        else if(ds%7==3){
            printf("Saturday\n");
        }
        else if(ds%7==4){
            printf("Sunday\n");
        }
    }
    return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a[20][30];
    int i=4;
    int x,y;
    for(int k=1;k<=31;k++)
    {
        a[1][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=29;k++)
    {
        a[2][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=31;k++)
    {
        a[3][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=30;k++)
    {
        a[4][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=31;k++)
    {
        a[5][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=30;k++)
    {
        a[6][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=31;k++)
    {
        a[7][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=31;k++)
    {
        a[8][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=30;k++)
    {
        a[9][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=31;k++)
    {
        a[10][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=30;k++)
    {
        a[11][k]=i;
        i++;
        if(i==8)i=1;
    }
    for(int k=1;k<=31;k++)
    {
        a[12][k]=i;
        i++;
        if(i==8)i=1;
    }
    while(cin>>x>>y)
    {
        if(x==0)break;
        if(a[x][y]==1)cout<<"Monday"<<endl;
        if(a[x][y]==2)cout<<"Tuesday"<<endl;
        if(a[x][y]==3)cout<<"Wednesday"<<endl;
        if(a[x][y]==4)cout<<"Thursday"<<endl;
        if(a[x][y]==5)cout<<"Friday"<<endl;
        if(a[x][y]==6)cout<<"Saturday"<<endl;
        if(a[x][y]==7)cout<<"Sunday"<<endl;
    }
    return 0;
}

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

int main(){

  int a[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
  int n,m,d;

  while(cin >> n >> m, n, m){

    d = 0;

    for(int i=0;i<n-1;i++) d = a[i] + d;
 
    d = d + m;

    while(d > 6) d -= 7;
   
    if(d == 5) cout << "Monday" << endl;
    else if(d == 6) cout << "Tuesday" << endl;
    else 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;

  }
}

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,29,
		 31,30,
		 31,30,
		 31,31,
		 30,31,
		 30,31};
  while(cin>>aa>>b,aa+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 getDay(int y,int m,int d){
	if(m<3) m += 12 , y--;
	int J = y/100 , K = y%100;
	return (d + ((m+1)*26)/10 + K + K/4 + J/4 - 2*J)%7;
}
int main(){
	string table[] = {"Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"};
	int m,d;
	while(cin >> m >> d , m){
		cout << table[getDay(2004,m,d)] << endl;
	}
}