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
//------------------------------------------
#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 <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;
typedef unsigned long long ULL;

//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 main() {
  int month, dates, day = 3;
  while(cin >> month >> dates) {
    if(month == 0)break;
    for(int i = 1; i < month; i++) {
      switch(i) {
      case 1:
      case 3:
      case 5:
      case 7:
      case 8:
      case 10:
      case 12:
	day += 31;
	break;
      case 2:
	day += 29;
	break;
      case 4:
      case 6:
      case 9:
      case 11:
	day += 30;
	break;
      }
    }

    day += dates-1;
    day %= 7;
    
    switch(day) {
    case 0:
      cout << "Monday" << endl;
      break;
    case 1:
      cout << "Tuesday" << endl;
      break;
    case 2:
      cout << "Wednesday" << endl;
      break;
    case 3:
      cout << "Thursday" << endl;
      break;
    case 4:
	cout << "Friday" << endl;
	break;
    case 5:
      cout << "Saturday" << endl;
	break;
    case 6:
      cout << "Sunday" << endl;
      break;
    }
  }
}

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

int main(){
	string week[7] = {"Mondey","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
	int m,d,cnt,mc;

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

		mc = 1;
		cnt = 3;
		while(1){
			for(int i=1 ; i <= month[mc-1] ; i++, cnt++){
				if(m==mc && d==i) break;
			}
			if(m==mc) break;
			mc++;
		}
		cout << week[cnt%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 5:
        cout << "Monday";
        break;
      case 6:
        cout << "Tuesday";
        break;
      case 0:
        cout << "Wednesday";
        break;
      case 1:
        cout << "Thursday";
        break;
      case 2:
        cout << "Friday";
        break;
      case 3:
        cout << "Saturday";
        break;
      case 4:
        cout << "Sunday";
        break;
      cout << endl;
    }
  }
}

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

int search(int a){
	int month;
	if(a==2) month = 29;
	else if(a%2!=0) month = 31;
	else month = 30;
	return month;
}

char *Whatday(int a,int b){
	int month;
	char *day;
	int date=0;
	
	for(int i=1;i<a;i++){
		date = date+search(i);
	}
	date += b;
	switch(date%7){
		case 0: day ="Wednesday"; break;
		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;
	}
	return day;
}

int main() {
	int m,d;
	while(1){
		cin >> m >> d;
		if(m==0) break;
		cout << Whatday(m,d) << endl;
	}
	return 0;
}

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

int days[13] = { 0,31,29,31,30,31,30,31,31,30,31,30,31};
string ans[10] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
int main()
{

int month, date;

	//前月までの延べ日数に変換
	for( int i = 1; i < 13; i++ ) {
		days[i] += days[i-1];
	}

	while( cin >> month >> date ) {
		if( month == 0 )
			return -1;
		
		int day = days[month-1] + date + 3;
		int p = day %7;

		cout << ans[p].c_str() << endl;

	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <algorithm>
#include <cctype>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);

int x,y,tu[11]={31,29,31,30,31,30,31,31,30,31,30};

int main(){
	while(1){
		cin>>x>>y;
		if(!x&&!y) break;
		int num=0;
		for(int i=0;i<x-1;i++) num+=tu[i];
		num+=y;
		int ans=num%7;
		if(ans==1) cout<<"Thursday"<<endl;
		else if(ans==2) cout<<"Friday"<<endl;
		else if(ans==3) cout<<"Saturday"<<endl;
		else if(ans==4) cout<<"Sunday"<<endl;
		else if(ans==5) cout<<"Monday"<<endl;
		else if(ans==6) cout<<"Tuesday"<<endl;
		else if(!ans) cout<<"Wednsday"<<endl;
	}
}

C++: #include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#define PI 3.1415926535897932384626433
using namespace std;
int main(){
    int days[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
    int rui[13]={0};
    for(int i=1;i<=12;i++)rui[i]=rui[i-1]+days[i];
    int a,b;
    while(cin>>a>>b){
        int p=rui[a-1]+b;
        if(p%7==0)cout<<"Wednesday"<<endl;
        if(p%7==1)cout<<"Thursday"<<endl;
        if(p%7==2)cout<<"Friday"<<endl;
        if(p%7==3)cout<<"Saturday"<<endl;
        if(p%7==4)cout<<"Sunday"<<endl;
        if(p%7==5)cout<<"Monday"<<endl;
        if(p%7==6)cout<<"Tuesday"<<endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <queue>
#include <stack>
#include <utility>
#include <queue>
#include <cmath>
#define mp make_pair
#define pii pair<int,int> 
#define ff first
#define ss second

using namespace std;

int month[20]={0,31,29,31,30,31,30,31,31,30,31,30,31};
string days[10]={" ","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
int a,b,c;
int main()
{
	while(1)
	{
		scanf("%d %d",&a,&b);
		c=0;
		if(a==0&&b==0)
		{
			break;
		}
		for(int i=1;i<a;i++)
		{
			c+=month[i];
		}
		c+=b;
		c%=7;
		c+=3;
		printf("%d\n",c);
		cout<<days[c]<<endl;
	}
	return 0;
}