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 <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define F first
#define S second
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl

string yobi[7]={
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday"
};

int main(){
	li m,d;
	li acum=3;
	li day[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	
	while(1){
		acum=3;
		cin>>m>>d;
		if(min(m,d)==0)break;
		
		rep(i,m-1)acum+=day[i];
		acum+=d-1;
		cout<<yobi[acum%7]<<endl;
	}
	
	return 0;
}

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

using namespace std;

int main(void){
    for(;;){
        int m,d;
        int data[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
        cin>>m>>d;
        if(m==0&&d==0)break;
        for(int i=1;i<=m;i++){
            d+=data[i-1];
        }
        switch(d%7){
            case 0: cout << "Wednesday" << 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;
        }
    }
	return 0;
}

C++: #include <stdio.h>
int main() {char *ans[7]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};int i,j,today[12]={4,0,1,4,6,2,4,0,3,5,1,3};while (1) {scanf("%d %d",&i,&j);if (!i && !j) return 0;puts(ans[(today[i-1]+j-1)%7]);}return 0;}

C++: #include <iostream>
int main(void){
    int month,day,chek;
    while(std::cin >> month >> day,month){ int year = 2004;
    if(month == 1 || month == 2){year--;month+=12;}
    chek = ((year+ year/4-year/100+year/400+(13*month+8)/5+day)%7);
    switch (chek) {case 0:puts("Sunday");break; case 1:puts("Monday");break; case 2:puts("Tuesday");break; case 3:puts("Wednesday");break;
        case 4:puts("Thursday");break; case 5:puts("Friday");break; case 6:puts("Saturday");break; }}return 0;}

C++: //31,29,31,30,31,30,31,31,30,31,30,31//
#include <iostream>
using namespace std;
int main(){
    int d,m;
    while(cin>>m>>d){
        if(m==0&&d==0)break;
        if(m==1)d=d%7;
        else if(m==2)d=(d+31)%7;
        else if(m==3)d=(d+60)%7;
        else if(m==4)d=(d+91)%7;
        else if(m==5)d=(d+121)%7;
        else if(m==6)d=(d+152)%7;
        else if(m==7)d=(d+182)%7;
        else if(m==8)d=(d+213)%7;
        else if(m==9)d=(d+244)%7;
        else if(m==10)d=(d+274)%7;
        else if(m==11)d=(d+305)%7;
        else d=(d+335)%7;
            if(d%7==1)cout<<"Thursday"<<endl;
            else if(d%7==2)cout<<"Fridy"<<endl;
            else if(d%7==3)cout<<"Saturday"<<endl;
            else if(d%7==4)cout<<"Sunday"<<endl;
            else if(d%7==5)cout<<"Monday"<<endl;
            else if(d%7==6)cout<<"Tuesday"<<endl;
            else cout<<"Wednesday"<<endl;
        
        }
    return 0;
}

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

using namespace std;

string today(int month, int day){
    string today;
    int startMonth=1, startDay=1, total=0;
    
    for(int i=startMonth; i<month; i++){
        switch(i){
            case 4:
            case 6:
            case 9:
            case 11:
                total += 30;
                break;
            
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                total += 31;
                break;
            case 2:
                total += 29;
                break;
        }
    }
    total += day;
    //cout << total%7 << endl;
    
    switch(total%7){
        case 1:
            today = "Thursday";
            break;
        case 2:
            today = "Friday";
            break;
        case 3:
            today = "Saturday";
            break;
        case 4:
            today = "Sunday";
            break;
        case 5:
            today = "Mondday";
            break;
        case 6:
            today = "Tuseday";
            break;
        case 0:
            today = "Wednesday";
            break;
    }
    
    
    return today;
}


int main (int argc, char const* argv[]){
    int month, day, n;
    
    cin >> month >> day;
    while(month!=0 && day!=0){
        
        cout << today(month,day)<< endl;
        cin >> month >> day;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int month[12] = {0,3,4,0,2,5,0,3,6,1,4,6};
  int m,d;
  while(cin >>m>>d,m||d){
    d = (d+month[m-1])%7;
    if(d == 1){cout <<"Thursday"<<endl;}
    if(d == 2){cout <<"Friday"<<endl;}
    if(d == 3){cout <<"Saturday"<<endl;}
    if(d == 4){cout <<"Sunday"<<endl;}
    if(d == 5){cout <<"Monday"<<endl;}
    if(d == 6){cout <<"Tuesday"<<endl;}
    if(d == 0){cout <<"Wednesday"<<endl;}
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main (){
	int a,b=0,c,tuki,hi;
	for(;;){
	cin>>tuki>>hi;
	if(tuki==0&&hi==0){
		break;
	}
	for(a=1;a<=hi;a++){
		b++;
	}
	if(tuki==1){
		b=b+31;
	}else if(tuki==2){
		b=b+31+29;
	}else if(tuki==3){
		b=b+31+29+31;
	}else if(tuki==4){
		b=b+31+29+31+30;
	}else if(tuki==5){
		b=b+31+29+31+30+31;
	}else if(tuki==6){
		b=b+31+29+31+30+31+30;
	}else if(tuki==7){
		b=b+31+29+31+30+31+30+31;
	}else if(tuki==8){
		b=b+31+29+31+30+31+30+31+31;
	}else if(tuki==9){
		b=b+31+29+31+30+31+30+31+31+30;
	}else if(tuki==10){
		b=b+31+29+31+30+31+30+31+31+30+31;
	}else if(tuki==11){
		b=b+31+29+31+30+31+30+31+31+30+31+30;
	}else if(tuki==12){
		b=b+31+29+31+30+31+30+31+31+30+31+30+31;
	}
	c=b%7;
	if(c==0){
		cout<<"Monday";
	}else if(c==1){
		cout<<"Tuesday";
	}else if(c==2){
		cout<<"Wednesday";
	}else if(c==3){
		cout<<"Thursday";
	}else if(c==4){
		cout<<"Friday";
	}else if(c==5){
		cout<<"Saturday";
	}else if(c==6){
		cout<<"Sunday";
	}
	cout<<endl;
	}
}

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

int main(void)
{
	int month, day, sum = 0, s_y = 3;
	int m_and_D[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	char select_y[7][10] = 
	{"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sanday"};

	while(scanf("%d %d",&month, &day) && month > 0)
	{
		s_y = 3;
		sum = 0;
		for(int f1 = 1; f1 < month; f1++)
		{
			sum += m_and_D[f1];
		}

		sum += day - 1;
		s_y = (sum + s_y) % 7;

		printf("%s\n",select_y[s_y]);
	}
	return 0;
}