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>

int main()
{
	std::vector<std::string> day_of_week{
		"Thursday",
		"Friday",
		"Saturday",
		"Sunday",
		"Monday",
		"Tuesday",
		"Wednesday"
	};

	std::vector<int> day_num_of_month{
		31,
		29,
		31,
		30,
		31,
		30,
		31,
		31,
		30,
		31,
		30,
		31
	};

	int month = 0;
	int day = 0;

	while (std::cin >> month >> day)
	{
		if (0 == month) { break; }

		int days_elapsed = 0;
		for (int m = 1; m < month; ++m)
		{
			days_elapsed += day_num_of_month[m - 1];
		}
		days_elapsed += day;

		std::cout << day_of_week[(days_elapsed - 1) % 7] << std::endl;
	}

	return 0;
}

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

int main()
{
    string day[]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
    int Mon[12]={31,29,31,30,31,30,31,31,30,31,30,31};
    int m,d;
    while(cin>>m>>d,m*d){
        int allDay=d;
        for(int i=1;i<m;i++){
            allDay += Mon[i];
        }
        cout<<day[allDay%7]<<endl;
    }
}

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

int main() {
	int month, day; cin >> month >> day;
	while (month != 0 && day != 0) {
		if (month >= 1) day = day;
		if (month >= 2) day = day + 31;
		if (month >= 3) day = day + 28;
		if (month >= 4) day = day + 31;
		if (month >= 5) day = day + 30;
		if (month >= 6) day = day + 31;
		if (month >= 7) day = day + 30;
		if (month >= 8) day = day + 31;
		if (month >= 9) day = day + 31;
		if (month >= 10) day = day + 30;
		if (month >= 11) day = day + 31;
		if (month >= 12) day = day + 30;
		if (day % 7 == 0) cout << "Wednesday" << endl;
		if (day % 7 == 1) cout << "Thursday" << endl;
		if (day % 7 == 2) cout << "Friday" << endl;
		if (day % 7 == 3) cout << "Saturday" << endl;
		if (day % 7 == 4) cout << "Sunday" << endl;
		if (day % 7 == 5) cout << "Monday" << endl;
		if (day % 7 == 6) cout << "Tuesday" << endl;
		cin >> month >> day;
	}
	return 0;
}

C++: #include <iostream>
int main(){
    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; }}}

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)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 if(m==12)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 if(d%7==0)cout<<"Wednesday"<<endl;
        
        }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main ()
{
    int m,d,r;

    while (1)
    {
        cin>>m>>d;
        if (m==0 || d==0)
            break;
        else
        {
            if (m==1)
                r=d;
            else if (m==2)
                r=31+d;
            else if (m==3)
                r=31+29+d;
            else if (m==4)
                r=31+29+31+d;
            else if (m==5)
                r=31+29+31+30+d;
            else if (m==6)
                r=31+29+31+30+31+d;
            else if (m==7)
                r=31+29+31+30+31+30+d;
            else if (m==8)
                r=31+29+31+30+31+30+31+d;
            else if (m==9)
                r=31+29+31+30+31+30+31+31+d;
            else if (m==10)
                r=31+29+31+30+31+30+31+31+30+d;
            else if (m==11)
                r=31+29+31+30+31+30+31+31+30+31+d;
            else if (m==12)
                r=31+29+31+30+31+30+31+31+30+31+30+d;
        }
        if (r%7==1)
            cout<<"Thursday"<<endl;
        else if (r%7==2)
            cout<<"Friday"<<endl;
        else if (r%7==3)
            cout<<"Saturday"<<endl;
        else if (r%7==4)
            cout<<"Sunday"<<endl;
        else if (r%7==5)
            cout<<"Monday"<<endl;
        else if (r%7==6)
            cout<<"Tuesday"<<endl;
        else if (r%7==0)
            cout<<"Wednesday"<<endl;
    }
}

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

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

const int month[] = {0, 31, 60, 91, 121, 152, 182, 212, 243, 273, 304, 334};
int main()
{
  int m, d, cntdays = 0;
  
  while (cin >> m >> d, m){
    cntdays = month[m - 1] + d;
    switch (cntdays % 7){
      case 0:
        cout << "Wednesday";
        break;
      case 1:
        cout << "Thursday";
        break;
      case 2:
        cout << "Friday";
        break;
      case 3:
        cout << "Saturday";
        break;
      case 4:
        cout << "Sunday";
        break;
      case 5:
        cout << "Monday";
        break;
      case 6:
        cout << "Tuesday";
        break;
    }
    cout << endl;
  }
}

C++: #include <iostream>
using namespace std;
int main(){
	int day[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
	int mon,d;
	while(cin>>mon>>d){
		int sum =0;
		if(mon == 0) break;
		for(int i=0;i<mon-1;i++){
			sum += day[i];
		}
		sum += d;
		int a = sum%7;
		if(a==1) cout<<"Thursday"<<endl;
		else if(a==2) cout<<"Friday"<<endl;
		else if(a==3) cout<<"Saturday"<<endl;
		else if(a==4) cout<<"Sunday"<<endl;
		else if(a==5) cout<<"Monday"<<endl;
		else if(a==6) cout<<"Tuesday"<<endl;
		else if(a==0) cout<<"Wednesday"<<endl;
	}
	return 0;
}

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

int n[12] = {31,29,31,30,31,30,31,31,30,31,30,31};

int totalday(int month, int day){
	int res = 0;
	for(int i=1; i<month; i++){
		res += n[i-1];
	}
	res += day;
	return res;
}

int main(void) {
	int month, day;
	while(cin >> month >> day){
		if(month==0 && day==0) break;
		int total = totalday(month, day);
		total = total % 7;

		switch(total){
		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;
		}
	}
	return 0;
}