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 main(){
  int day30[4] = {4,6,9,11};
 
  while(1) {
  int m,d;
  cin >> m >> d;
  if(m == 0 && d == 0) break;
  int a = 1,b = 1,count = 0;
 
  while(1) {
 
    if(a == m && b == d) break;
     
    b++;
    count++;
 
    if(a == 2 && b == 30) {
      a++;
      b = 1;
    }
    else if(b == 31) {
      for(int i=0;i<4;i++) 
    if(day30[i] == a) {
      a++;
      b = 1;
      break;
    }
    }
    if( b == 32) {
      a++;
      b = 1;
    }
  }
   
  if(count % 7 == 4 ) cout <<"Monday"<<endl;
  else if(count % 7 == 5) cout << "Tuesday"<<endl;
  else if(count % 7 == 6) cout <<"Wednesday"<< endl;
  else if(count % 7 == 0) cout <<"Thursday"<< endl;
  else if(count % 7 ==1) cout << "Friday" << endl;
  else if(count % 7 ==2)cout << "Saturday" << endl;
  else if(count % 7 ==3) cout << "Sunday" << endl;
   
  }
 
return 0;

}

C++: #include <iostream>

using namespace std;

int main()
{
	int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	int m, d;
	
	while (true) {
		cin >> m >> d;
		if (m==0 || d==0) break;
		
		int day = 3; // 2013/12/31 is Wednesday
		
		for (int i=0; i<m-1; i++) day += month[i];
		day += d;
		
		switch (day%7) {
		case 0 :
			cout << "Sunday"; break;
		case 1 :
			cout << "Monday"; break;
		case 2 :
			cout << "Tuesday"; break;
		case 3 :
			cout << "Wednesday"; break;
		case 4 :
			cout << "Thursday"; break;
		case 5 :
			cout << "Friday"; break;
		case 6 :
			cout << "Saturday"; break;
		}
		cout << endl;
	}
	
	return 0;
}

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

string data[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
int day[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int m, d;
	while(cin >> m >> d && m != 0){

		for(int i = 0; i < m - 1; ++i){
			d += day[i];
		}

		d -= 1;
		cout << data[(d + 3) % 7] << endl;
	}

	return 0;
}

C++: #include <cstdio>

int main() {
    int inm = 0;
    int ind = 0;
    while (scanf("%d %d", &inm, &ind) != EOF) {
        if ((inm == 0) && (ind == 0)) {
            break;
        }

        const int m[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
        int d = 2;

        for (int i = 0; i < inm; ++i) {
            for (int j = 0; j < m[i]; ++j) {
                if (d == 6) {
                    d = 0;
                } else {
                    d++;
                }

                if ((i == inm - 1) && (j == ind - 1)) {
                    goto end;
                }
            }
        }

        end:
        switch (d) {
        case 0:
            printf("Monday\n");
            break;
        case 1:
            printf("Tuesday\n");
            break;
        case 2:
            printf("Wednesday\n");
            break;
        case 3:
            printf("Thursday\n");
            break;
        case 4:
            printf("Friday\n");
            break;
        case 5:
            printf("Saturday\n");
            break;
        case 6:
            printf("Sunday\n");
            break;
    }
    }
    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

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

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;

#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())

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

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

#define CLR(a) memset((a), 0 ,sizeof(a))

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

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

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

    for(int i=0;m-1>i;i++){
      if(m==1)break;
      else d+=mon[i];

  }
    k=d%7+2;
    cout <<today[k]<<endl;
  
  }
}

C++: #include<stdio.h>
int main(void)
{
	int y,m,d;
	int i;
	int ans;
	
	y=2004;
	
	for(;;)
	{
		scanf("%d%d",&m,&d);
		if(m==0 && d==0)
			break;
		
		ans=0;
		
		ans=(y-1)*365+y/4-y/100+y/400;
		
		for(i=1;i<m;i++)
		{
			if(i==2 && (y/4==0 && y/100!=0) || y/400==0)
				ans+=29;
			else if(i==2)
				ans+=28;
			else if(i<8 && i%2==0)
				ans+=30;
			else if(i<8 && i%2!=0)
				ans+=31;
			else if(i>7 && i%2==0)
				ans+=30;
			else
				ans+=31;
		}
		
		ans+=d;
		
		if(m<3 && ((y%4==0 && y%100!=0) || y%400==0))
			ans-=1;
		
		switch(ans%7)
		{
			
			case 0:
				printf("Sunday\n");
				break;
			case 1:
				printf("Monday\n");
				break;
			case 2:
				printf("Tuesday\n");
				break;
			case 3:
				printf("Wednesday\n");
				break;
			case 4:
				printf("Thursday\n");
				break;
			case 5:
				printf("Friday\n");
				break;
			case 6:
				printf("Saturday\n");
				break;
		}
	}
		
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
 
#define REP(i,b,n) for(int i=b;i<n;++i)
#define REPR(i,b,n) for(int i=n-1;i>=b;--i)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#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 BIT(n, b) ((n>>b) & 1)
#define PI acos(-1.0)

using namespace std;

static const double EPS = 1e-9;
typedef pair<int, int> pii;
typedef long long ll;

int mday[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string week[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

int main(){
		
	int m, d;
	
	while(cin>>m>>d, (m||d)){
		
		int dsum = 3;
		
		for(int i = 0; i < m; ++i){
			dsum += mday[i];
		}
		
		cout << week[dsum%7] << endl;
	}
	
	return 0;
}

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


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