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>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())

#define rep(i,n) for(int i = 0; i < (n);++i)
#define repc(i,a,b) for(int i = (a);i <(b);++i)
#define repa(n,array) for(auto n :(array))

typedef long long ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;

constexpr int IMAX = ((1<<30)-1)*2+1 ;
constexpr int INF = 100000000;
double EPS = 1e-10 ;

const int month[12] = {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,date = 3;
  while(1){
    cin >> m >> d ;
    if(m == 0){
      break ;
    }
    for(int i = 0;i < m-1;++i){
      date += month[i] % 7 ;
    }
    date += d % 7 - 1 ;
    switch(date%7){
      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;
      default:
        break;
    }
  }
  return 0;
}

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

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

int main(){
	int M, D;
	while( cin >> M >> D, M ){
		int d = 3;
		for(int i=0; i<M-1; i++ ){
			d += month[i];
		}
		d += D;
		d %= 7;
		cout << date[d] << endl;
	}
}

C++: #include<iostream>

using namespace std;

int main()
{
	char *week[7]={ "Thursday",
					"Friday",
					"Saturday",
					"Sunday",
					"Monday",
					"Tuesday",
					"Wednesday"};
	int mouse[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	int tuki,day;

	while(cin>>tuki>>day,tuki,day){
		int now=0;
		now+=day-1;
		for(tuki=tuki-2;tuki>=0;tuki--)
			now+=mouse[tuki];
		cout<<week[now%7]<<endl;
	}

	return 0;
}

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

int day(int month){
	switch(month){
		case 4:
		case 6:
		case 9:
		case 11:
			return 30;
			break;
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			return 31;
			break;
		case 2:
			return 18;
			break;
	}
}

int main(){
	int m, d, num;
	while(cin >> m >> d, m || d){
		num = 0;
		for(int i=1; i < m; i++){
			num += day(i);
		}
		num += d;
		switch(num % 7){
			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;
		}
	}
}

C++: #include<iostream>
using namespace std;
 
int main(){
    int month[]={31,29,31,30,31,30,31,31,30,31,30,31};
    int sum[13];
    char *week[]={"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
    int m,d;
    sum[0]=0;
    for(int i=1;i<=12;i++)sum[i] = sum[i-1]+month[i-1];
    while(cin>>m>>d,m||d)cout<<week[(sum[m-1]+d-1)%7]<<endl;
    return 0;
}

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

int main(void){

    string day[7] = {"Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"};
    //int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
    int x,y;

    while(cin >> x >> y){
        int h = 20;
        int n = 4;
        if(x == 0){
            return 0;
        }
        if(x == 1 || x == 2){
            n--;
            x+=12;
        }
                       
        int w = n + n/4 + h/4 - 2*h + 13*(x+1)/5 + y;
        //cout << w << endl;
       
        //cout << w%7 << endl;

        string ans = day[w%7];

        cout << ans << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <string>

using namespace std;

int main (void) {
	int months[12];
	
	months[ 1 - 1] = 31;
	months[ 2 - 1] = 29;
	months[ 3 - 1] = 31;
	months[ 4 - 1] = 30;
	months[ 5 - 1] = 31;
	months[ 6 - 1] = 30;
	months[ 7 - 1] = 31;
	months[ 8 - 1] = 31;
	months[ 9 - 1] = 30;
	months[10 - 1] = 31;
	months[11 - 1] = 30;
	months[12 - 1] = 31;
	
	string days[7] = {
		"Thursday",
		"Friday",
		"Saturday",
		"Sunday",
		"Monday",
		"Tuesday",
		"Wednesday"
	};
	
	for (;;) {
		int m, d, dSum;
		cin >> m;
		cin >> d;
		
		if (m == 0 && d == 0) {
			break;
		}
		
		dSum = 0;
		for (int i = 0; i < m - 1; i ++) {
			dSum += months[i];
		}
		
		dSum += d - 1;
		
		cout << days[dSum % 7] << 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+2;
		c%=7;
		printf("%d\n",c);
		cout<<days[c]<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <utility>
using namespace std;
typedef pair<int,int> MonthDay;
int main(){
  int monthnum[]={
    31,29,31,30,31,30,31,31,30,31,30,31
  };
  const string weekname[]={
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday",
    "Sunday"
  };
  vector<MonthDay> data;
  int month,day;
  while(cin>>month>>day){
    if(!month)break;
    data.push_back(MonthDay(month,day));
  }
  for(int i=0;i<data.size();i++){
    int daysum=0;
    for(int j=0;j<data[i].first-1;j++){
      daysum+=monthnum[j];
    }
    daysum+=data[i].second;
    int weekindex=(daysum+2)%7;
    cout<<weekname[weekindex]<<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];
    while(1){
        int a,b;
        cin>>a>>b;
        if(a==0&&b==0)break;
        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;
}