Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
	"time"
)

var sc = bufio.NewScanner(os.Stdin)

//Sliceconvtoi ...
func Sliceconvtoi() []int {
	strs := strings.Split(sc.Text(), " ")

	var ints []int
	var x int

	for _, s := range strs {
		x, _ = strconv.Atoi(s)
		ints = append(ints, x)
	}

	return ints
}

func main() {
	for sc.Scan() {
		i := Sliceconvtoi()

		if i[0] == 0 && i[1] == 0 {
			break
		}

		m := time.Month(i[0])
		d := i[1]
		t := time.Date(2004, m, d, 0, 0, 0, 0, time.Local)
		fmt.Println(t.Weekday())
	}

}

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;
	}
}

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;
}

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

int zeller(int y, int m , int d) {
  if (m < 3) y--, m += 12;
  return (y + y / 4 - y / 100 + y / 400 + (13 * m + 8) / 5 + d) % 7;
}

int main() {
  char day[7][15] = {"Sunday", "Monday", "Tuesday", "Wednesday",
                     "Thursday","Friday","Saturday"};
  int m, d;
  while (scanf("%d%d", &m, &d), m) {
    puts(day[zeller(2004, m, d)]);
  }
}