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 <string>
using namespace std;

int main()
{
	int month,day;
	int months[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
	string days[7] = {"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wndnessday"};
	while(cin >> month >> day)
	{
		if(month == 0) break;
		else
		{
			int sum = 0;
			for(int i=0;i<month-1;i++)
			{
				sum += months[i];
			}
			sum += day;
			cout << days[sum%7-1] << endl;
		}
	}
	return 0;
}

C++: //#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <math.h>
#include<algorithm>
#include <utility>
using namespace std;
int main() {//Thursda,Friday...0,1,2,3,4,5,6
	int month,day, today;//31%7=3
	int add=0;
	while (1) {
		cin >> month >> today;
		if (month == 0) {
			break;
		}
		if (month == 1) {
			add = 0;
		}
		else {
			for (int i = 1; i < month; i++) {
				if (i == 2) {
					add+=1;
				}
				else if (i % 2 == 0 && i < 8 || i == 11) {
					add += 2;
				}
				else {
					add += 3;
				}
			}
		}
		today += add;
		day = today%7;
		switch (day) {
		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;
		case 0:cout << "Wednesday" << endl; break;
		}
		add = 0;
	}
	return 0;
}

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