Go: package main

import "fmt"

func main() {
	days := [12]int{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
	weekday := [7]string{"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}

	for {
		var m, d int
		fmt.Scan(&m, &d)
		if m == 0 {
			break
		}

		for i := 0; i < m-1; i++ {
			d += days[i]
		}

		fmt.Println(weekday[d%7])
	}
}

C++: 
// @snippet<sh19910711/contest:headers.cpp>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <limits>
#include <complex>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

// @snippet<sh19910711/contest:solution/interface.cpp>
namespace solution {
    class ISolution {
    public:
        virtual void init() {};
        virtual bool input() { return false; };
        virtual void output() {};
        virtual int run() = 0;
    };
}

// @snippet<sh19910711/contest:solution/typedef.cpp>
namespace solution {
    typedef std::istringstream ISS;
    typedef std::ostringstream OSS;
    typedef std::vector<std::string> VS;
    typedef long long LL;
    typedef int INT;
    typedef std::vector<INT> VI;
    typedef std::vector<VI> VVI;
    typedef std::pair<INT,INT> II;
    typedef std::vector<II> VII;
}

// @snippet<sh19910711/contest:misc/date.cpp>
namespace misc {
    class Date {
    public:
        int getYear() { return yy; }
        int getMonth() { return mm; }
        int getDate() { return dd; }
        int getDay() {
            int y = yy, m = mm;
            if ( mm <= 2 )
                y -= 1, m += 12;
            int k = y % 100;
            int j = y / 100;
            return ( dd + 13*(m+1)/5 + k + k/4 + j/4 + 5*j + 5 ) % 7;
        }
        static std::string getDayString( const int& day ) {
            const std::string T[7] = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
            return T[day];
        }
        void init( const int& yy_, const int& mm_, const int& dd_ ) { yy = yy_, mm = mm_, dd = dd_; }
        static bool isLeapYear( int y ) { return y % 100 == 0 ? y % 400 == 0 : y % 4 == 0; }
        virtual std::string toString() {
            std::ostringstream oss;
            oss << std::setw(4) << std::setfill('0') << yy << "/";
            oss << std::setw(2) << std::setfill('0') << mm << "/";
            oss << std::setw(2) << std::setfill('0') << dd;
            return oss.str();
        }
        Date& operator ++() {
            dd ++;
            int ld = this->days[mm] + ( mm == 2 && Date::isLeapYear(yy) ? 1 : 0 );
            if ( dd > ld ) dd = 1, mm ++;
            if ( mm > 12 ) mm = 1, yy ++;
            return *this;
        }
        Date& operator --() {
            dd --;
            if ( dd == 0 ) mm --;
            if ( mm == 0 ) mm = 12, yy --;
            int ld = this->days[mm] + ( mm == 2 && Date::isLeapYear(yy) ? 1 : 0 );
            dd = ld;
            return *this;
        }
    protected:
        int yy, mm, dd;
        friend bool operator <( const Date& l, const Date& r ) {
            return l.yy == r.yy ? ( l.mm == r.mm ? ( l.dd == r.dd ? false : l.dd < r.dd ) : l.mm < r.mm ) : l.yy < r.yy;
        }
        friend bool operator ==( const Date& l, const Date& r ) {
            return l.yy == r.yy && l.mm == r.mm && l.dd == r.dd;
        }
        friend bool operator <=( const Date& l, const Date& r ) {
            return operator <(l, r) || operator ==(l, r);
        }
    private:
        static const int days[13];
    };
    const int Date::days[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
}


// @snippet<sh19910711/contest:solution/solution.cpp>
namespace solution {
    using namespace std;
    
    int m, d;
    
    class Solution: public ISolution {
    public:
        bool input() {
            if ( ! ( cin >> m >> d ) )
                return false;
            if ( m == 0 && d == 0 )
                return false;
            return true;
        }
        string solve() {
            misc::Date date;
            date.init( 2004, m, d );
            return misc::Date::getDayString(date.getDay());
        }
        void output( string result ) {
            cout << result << endl;
        }
        int run() {
            while ( init(), input() ) {
                output(solve());
            }
            return 0;
        }
    };
}

// @snippet<sh19910711/contest:main.cpp>

int main() {
    return solution::Solution().run();
}

C++: #include<iostream>
using namespace std;
int main(){
  int a,b;
  int day[12] = {0,3,4,0,2,5,0,3,6,1,4,6};
  while(cin >>a>>b,a||b){
    b+=day[a-1];
    switch(b%7){
    case 0:
      cout <<""<<endl;
      break;
    case 1:
      cout <<"Thursday"<<endl;
      break;
    case 2:
      cout <<"Friday"<<endl;
      break;
    case 3:
      cout <<"Saturday"<<endl;
      break;
    case 4:
      cout <<"Sunday"<<endl;
      break;
    case 5:
      cout <<"Monday"<<endl;
      break;
    case 6:
      cout <<"Tuesday"<<endl;
      break;
    }
  }
}

C++: #include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000007
#define EPS 1E-12

string s[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
const int y = 2004;
int m, d;

int main()
{
  while((cin >> m >> d) && m){
    int D = (d + 26*(m+1)/10 + y + y/4 + -2*(y/100) + y/100/4 + 5) % 7;
    cout << s[D] << endl;
  }


  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

class DayOfWeek {
	static const int m_startw = 4;

	int m_month;
	int m_day;

public:
	DayOfWeek( int mon, int day ):
		m_month( mon-1 ),
		m_day( day-1 )
	{}

	int days() const {
		static const int mdays[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };

		int d = m_day;
		for( int i = 0; i < m_month; ++i ) {
			d += mdays[i];
		}

		return d;
	}

	string name() const {
		static const string names[] = {
			"Sunday",
			"Monday",
			"Tuesday",
			"Wednesday",
			"Thursday",
			"Friday",
			"Saturday"
		};

		return names[(days() + m_startw) % 7];
	}
};

int main() {
	ios_base::sync_with_stdio( false );

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

		cout << DayOfWeek( m, d ).name() << '\n';
	}
}