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 <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int main() {
	int day=0;
	int x,y;
	int md[12]={30,29,31,30,31,30,31,31,30,31,30,31};
	string s[7]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
	while(true){
		cin>>x>>y;
		if(x==0) break;
		for(int i=0;i<x-1;i++){
			day+=md[i];
		}
		day+=y;
		day%=7;
		cout<<s[day]<<endl;		
	}
}

C++: #include <iostream>

int main(){
    int m, d, w;
    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;
        }
        w = 3;
        for(int i = 1; i < m; i++){
            w += days[i - 1];
        }
        w += d; 
        std::cout << weekName[w % 7] << std::endl;
    }
}

C++: #include<iostream>
#include <stdio.h>
#include <time.h>
#include<string>
using namespace std;
int main(){
  int f,i,p,count,s,q,type1,type2,type3,type4;
 for(;;){
      count=0;
      s=0;
      p=0;
       q=0;
     cin>>f;
      type1=(f==1||f==10);type2=(f==2||f==3||f==11);type3=(f==4||f==7);type4=(f==9||f==12);
          cout<<"  S  M  T  W  t  F  s"<<endl;
          cout<<endl;
          if(type1){
              count=-1;
              cout<<"   ";
          }
          else if(type2){
          count=-4;
          cout<<"            ";
          }
          else if(type4){
          count=-6;
          cout<<"                  ";
          }
          else if(f==5){
          count=-2;
          cout<<"      ";
          }
          else if(f==6){
              count=-5;
          cout<<"               ";
          }
          else if(f==8){
          count=-3;
          cout<<"         ";
          }if(f==2){
           q=28;
           }
           else if(f==1||f==3||f==5||f==7||f==8||f==10||f==12){
           q=31;
           }    
           else if(f==4||f==6||f==9||f==11){
           q=30;
           }
          for(i=1;i<=37;i++){
              count++;
              if(count<1){
              continue;
              }
          printf("%3d",count);
          if(i%7==0){
          cout<<endl;
          }
          if(count==q){
              break;
              }
          }
          cout<<endl<<endl;
          }
 return 0;
}

C++: #include <stdio.h>

int m ;
int d ;
int dayc ;

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

int main ( )
{
	while ( scanf ( "%d %d" , &m , &d ) == 2 && m && d ) {
		dayc = 0 ;
		for ( int i = 0 ; i < m ; i++ ) {
			dayc += days[i] ;
		}
		dayc += d ;
		dayc-- ;
		dayc %= 7 ;
		switch ( dayc ) {
			case 0 :
				printf ( "Thursday\n" ) ;
				break ;
			case 1 :
				printf ( "Friday\n" ) ;
				break ;
			case 2 :
				printf ( "Saturday\n" ) ;
				break ;
			case 3 :
				printf ( "Sunday\n" ) ;
				break ;
			case 4 :
				printf ( "Monday\n" ) ;
				break ;
			case 5 :
				printf ( "Tuesday\n" ) ;
				break ;
			case 6 :
				printf ( "Wednesday\n" ) ;
				break ;
		}
	}
	return 0 ;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main() {
    int dates[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    string days[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

    int m,d;
    while (cin >> m >> d && m != 0 || d != 0) {
        int day = 2;
        for (int i=0; i<m-1; ++i) {
            day = (day + dates[i]) % 7;
        }
        day = (day + d) % 7;

        cout << days[day] << endl;
    }
}

C++: #include<iostream>
#include<string>
int main(){
	int month,day;
	const int monthday[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	const std::string week[7]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	const int a=3;
	while(1){
		std::cin>>month>>day;
		if(month==0)break;
		int sum=day+a;
		for(int i=0;i<month-1;i++)sum+=monthday[i];
		std::cout<<week[(sum-1)%7]<<std::endl;
	}
	return 0;
	/*
	月曜日 Monday
	火曜日 Tuesday
	水曜日 Wednesday
	木曜日 Thursday
	金曜日 Friday
	土曜日 Saturday
	日曜日 Sunday
	*/
}

C++: #include<iostream>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll;

const int MNUM = 12, leapMNUM = 12;
const int ML[] = {31,28,31,30,31,30,31,31,30,31,30,31};      //day/month in usual year
const int leapML[] = {31,29,31,30,31,30,31,31,30,31,30,31};  //day/month in leap year
const string days[] = {"Sunday","Monday","Tuesday","Wednesday","Thursay","Friday","Saturday"};

struct date{
  int y,m,d;

  date(void):y(0),m(1),d(1){}
  date(int a,int b,int c):y(a),m(b),d(c){}
  
  bool isLeap(void){
    if(y%400==0)return true;
    if(y%100==0)return false;
    if(y%4==0)return true;
    return false;
  }

  date next(void){
    d++;
    if(isLeap()){
      if(leapML[m-1]<d){ d=1; m++; }
      if(leapMNUM<m){ m=1; y++; }
    }else{
      if(ML[m-1]<d){ d=1; m++; }
      if(MNUM<m){ m=1; y++; }
    }
    return *this;
  }

  bool operator==(const date x)const{return (y==x.y && m==x.m && d==x.d);}

  bool operator<(const date x)const{
    if(y!=x.y)return y<x.y;
    if(m!=x.m)return m<x.m;
    return d<x.d;
  }

  bool operator<=(const date x)const{return (*this==x || *this<x); }
  bool operator>(const date x)const{return !(*this<=x);}
  bool operator>=(const date x)const{return !(*this<x);}

  ll dayCount(void)const{
    date tmp;
    for(ll res=0;;res++){
      if(tmp==*this)return res;
      tmp.next();
    }
    return 0;
  }

  ll operator-(const date x)const{
    return dayCount() - x.dayCount();
  }

  //calculate days from Julian Day(-4713/01/01) using Fliegel's formula.
  ll Fliegel(void){
    int a = (14-m)/12, Y = y+4800-a, M = m+12*a-3;
    return (ll)d + (153*M+2)/5 + 365*Y + Y/4 - Y/100 + Y/400 - 32045;
  }

  //calculate day of week using Zeller congruence.
  int Zeller(void){
    int Y = y, M = m;
    if(M<3){ Y--; M+=12; }
    return (Y + Y/4 - Y/100 + Y/400 + (13*M+8)/5 + d)%7;
  }
};

int main(){
  int m,d;
  while(cin >> m >> d,m||d)
    cout << days[date(2004,m,d).Zeller()] << endl;
}