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
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <queue>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int gcd(int a, int b){
   int tmp;
   while(a%b==0){
      tmp=a%b;
      a=b;
      b=tmp;
   }
}

int lcm(int a,int b){
   return a*b/gcd(a,b);
}

bool prime_number(int n){
   vector<bool> i;
   if(n < 2){
      return false;
   }
   else if(n == 2){
      return true;
   }
   if(n % 2 == 0){
      return false;
   }
   for(int i=3;i<=n/i;i+=2){
      if(n % i == 0) return false;
      return true;
   }
}

int main(){
   int i,j;
   
   while(cin>>i>>j,i+j){
      if(i>1) j+=31;
      if(i>2) j+=29;
      if(i>3) j+=31;
      if(i>4) j+=30;
      if(i>5) j+=31;
      if(i>6) j+=30;
      if(i>7) j+=31;
      if(i>8) j+=31;
      if(i>9) j+=30;
      if(i>10) j+=31;
      if(i>11) j+=30;
      if(j%7==1) cout << "Thursday" << endl; 
      if(j%7==2) cout << "Friday" << endl; 
      if(j%7==3) cout << "Saturday" << endl; 
      if(j%7==4) cout << "Sunday" << endl; 
      if(j%7==5) cout << "Monday" << endl; 
      if(j%7==6) cout << "Tuesday" << endl; 
      if(j%7==0) cout << "Wednesday" << endl; 
   }
}

C++: #include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
    int day,mon[]={31,29,31,30,31,30,31,31,30,31,30,31},now,ans;
    for(;;){
    ans=0;
    cin>>now>>day;
    if(now==0)break;
    for(int i=0;i<now-1;i++){
        ans+=mon[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");
}
}

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

int main(){
  int m,d;
  string w[7] = {
    "Thursday","Friday","Saturday","Sunday",
    "Monday","Tuesday","Wednesday",
 };
  int p[12] = { 
    31,29,31,30,31,30,
    31,31,30,31,30,31 };


  while( cin>>m>>d && (m) ){
    --d;
    for( int i=0;i+1<m;i++ )
      d += p[i];
    //    cout << "d="<<d<<endl;

    cout << w[ d%7 ] << endl;
  }

  return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
int date,month,day;
while(cin>>month>>day&&month!=0)
{	
switch(month)
{
case 1:
switch(date%7)
{
case 1:
day=4;
break;
case 2:
day=5;
break;
case 3:
day=6;
break;
case 4:
day=7;
break;
case 5:
day=1;
break;
case 6:
day=2;
break;
case 0:
day=3;
break;
}
break;
case 2:
switch(date%7)
{
case 1:
day=7;
break;
case 2:
day=1;
break;
case 3:
day=2;
break;
case 4:
day=3;
break;
case 5:
day=4;
break;
case 6:
day=5;
break;
case 0:
day=6;
break;
}
break;
case 3:
switch(date%7)
{
case 1:
day=1;
break;
case 2:
day=2;
break;
case 3:
day=3;
break;
case 4:
day=4;
break;
case 5:
day=5;
break;
case 6:
day=6;
break;
case 0:
day=7;
break;
}
break;
case 4:
switch(date%7)
{
case 1:
day=4;
break;
case 2:
day=5;
break;
case 3:
day=6;
break;
case 4:
day=7;
break;
case 5:
day=1;
break;
case 6:
day=2;
break;
case 0:
day=3;
break;
}
break;
case 5:
switch(date%7)
{
case 1:
day=6;
break;
case 2:
day=7;
break;
case 3:
day=1;
break;
case 4:
day=2;
break;
case 5:
day=3;
break;
case 6:
day=4;
break;
case 0:
day=5;
break;
}
break;
case 6:
switch(date%7)
{
case 1:
day=2;
break;
case 2:
day=3;
break;
case 3:
day=4;
break;
case 4:
day=5;
break;
case 5:
day=6;
break;
case 6:
day=7;
break;
case 0:
day=1;
break;
}
break;
case 7:
switch(date%7)
{
case 1:
day=4;
break;
case 2:
day=5;
break;
case 3:
day=6;
break;
case 4:
day=7;
break;
case 5:
day=1;
break;
case 6:
day=2;
break;
case 0:
day=3;
break;
}
break;
case 8:
switch(date%7)
{
case 1:
day=7;
break;
case 2:
day=1;
break;
case 3:
day=2;
break;
case 4:
day=3;
break;
case 5:
day=4;
break;
case 6:
day=5;
break;
case 0:
day=6;
break;
}
break;
case 9:
switch(date%7)
{
case 1:
day=3;
break;
case 2:
day=4;
break;
case 3:
day=5;
break;
case 4:
day=6;
break;
case 5:
day=7;
break;
case 6:
day=1;
break;
case 0:
day=2;
break;
}
break;
case 10:
switch(date%7)
{
case 1:
day=5;
break;
case 2:
day=6;
break;
case 3:
day=7;
break;
case 4:
day=1;
break;
case 5:
day=2;
break;
case 6:
day=3;
break;
case 0:
day=4;
break;
}
break;
case 11:
switch(date%7)
{
case 1:
day=1;
break;
case 2:
day=2;
break;
case 3:
day=3;
break;
case 4:
day=4;
break;
case 5:
day=5;
break;
case 6:
day=6;
break;
case 0:
day=7;
break;
}
break;
case 12:
switch(date%7)
{
case 1:
day=3;
break;
case 2:
day=4;
break;
case 3:
day=5;
break;
case 4:
day=6;
break;
case 5:
day=7;
break;
case 6:
day=1;
break;
case 0:
day=2;
break;
}
break;
}
switch(day)
{
case 1:
cout<<"Monday"<<endl;
break;
case 2:
cout<<"Tuesday"<<endl;
break;
case 3:
cout<<"Wednesday"<<endl;
break;
case 4:
cout<<"Thursday"<<endl; 
break;
case 5:
cout<<"Friday"<<endl;
break;
case 6:
cout<<"Saturday"<<endl;
break;
case 7:
cout<<"Sunday"<<endl;
break;
}
}
return 0;
}