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<stdlib.h>
#include<stdio.h>

int main(){
  int m[366],d[366],i,add,n,num[366];
  i=0;
  do{
    scanf("%d %d",&m[i],&d[i]);
    ++i;
  }while(m[i-1]!=0);
  for(n=0;n<i-1;++n){
    add=0;
    switch(m[n]){
    case 12:
      add+=30;
    case 11:
      add+=31;
    case 10:
      add+=30;
    case 9:
      add+=31;
    case 8:
      add+=31;
    case 7:
      add+=31;
    case 6:
      add+=31;
    case 5:
      add+=30;
    case 4:
      add+=31;
    case 3:
      add+=29;
    case 2:
      add+=31;
    case 1:
      add+=0;
    
    }

    num[n]=(add+d[n])%7;
  
    switch(num[n]){
    case 0:
      printf("Wednesday\n");
      break;
    case 1:
      printf("Thursday\n");
      break;
    case 2:
      printf("Friday\n");
      break;
    case 3:
      printf("Saturday\n");
      break;
    case 4:
      printf("Sunday\n");
      break;    
    case 5:
      printf("Monday\n");
      break;    
    case 6:
      printf("Tuesday\n");
      break;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
int stoi(string x){stringstream ss;ss<<x;int tmp;ss>>tmp;return tmp;}
string itos(int x){stringstream ss;ss<<x;return ss.str();}
int cal[12]={31,29,31,30,31,30,31,31,30,31,30,31};//2は29,4,6,9,11は30
string ta[7]={"Thurthday","Fryday","Saturday","Sunday","Monday","Tuesday","Wednesday"};//1月１日が木曜日
int main(){
	int n,m,sum=0,now=0;
	cin>>n>>m;
	for(int i=0;i<n-1;i++)sum+=cal[i];
	sum+=m;
	sum--;
	for(int i=0;i<sum;i++)(now==6)?now=0:now++;
	cout<<ta[now]<<endl;
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main( void )
{
	int days[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	string d[7] = { "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday" };

	while (1)
	{
		int month;
		int day;
		cin >> month >> day;
		if ( month == 0 && day == 0 )
			break;

		for ( int i = 0; i < 11; i++ )
		{
			days[i+1] += days[i];
		}

		if ( month != 1 )
		{
			month -= 2;
			day += days[month];
		}
		day--;
		cout << d[day%7] << endl;

	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define drep(n,m) for(int i=0;i<n;i++)for(int j=0;j<m;j++)
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

ll gcd(ll a,ll b){
    if(a<b){
        int t=a;a=b;b=t;
    }
    int c=a%b;
    while(c!=0){
        a=b;
        b=c;
        c=a%b;
    }
    return b;
}

ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}

bool isPrime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0)return false;
    }
    return true;
}

int main() {
    string day[7]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
    int t=3;
    int v[12]={31,29,31,30,31,30,31,31,30,31,30,31};
    int mo,da;
    while(cin>>mo>>da){
        if(mo==0&&da==0)break;
        rep(i,1,13){
            rep(j,1,v[i-1]+1){
                if(i==mo&&j==da){
                    cout<<day[t]<<endl;
                    goto AWAY;   
                }
                t++;
                if(t==7)t=0;
            }
        }
        AWAY:;
    }
    
  
    return 0;
}

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

int main() {

  int data[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int month, day;
  while( cin >> month >> day, month + day ) {
    int sum = 0;
    for(int i=0; i<month-1; i++) {
      sum += data[i];
    }
    sum += day;
    sum %= 7;

    if( sum == 1 ) {
      cout << "Thursday" << endl;
    }
    else if( sum == 2 ) {
      cout << "Friday" << endl;
    }
    else if( sum == 3 ) {
      cout << "Saturday" << endl;
    }
    else if( sum == 4 ) {
      cout << "Sunday" << endl;
    }
    else if( sum == 5 ) {
      cout << "Monday" << endl;
    }
    else if( sum == 6 ) {
      cout << "Thuesday" << endl;
    }
 else if( sum == 0 ) {
      cout << "Wednesday" << endl;
    }
  }
}

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

int main(){
  string y[7]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
  int num[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};

  while(1){
    int m,d;
    cin >> m >> d;
    if( m == 0 && d == 0 ) break;
    while( m != 0 ){
      d += num[m-1];
      m--;
    }
    cout << y[d%7] << endl;
  }

  return 0;
}

C++: #include<iostream>
using namespace std;
int a[13][32];
void day(void)
{
    int check=3;
    for(int i=1;i<13;i++){
        for(int j=1;j<32;j++){
            a[i][j]=check;
            check++;
            if(check==7)check=0;
            if((i==4||i==6||i==9||i==11)&&j==30)break;
            else if(i==2&&j==29)break;
        }
    }
}
int main()
{
    int mon,date;
    day();
    while(1){
        cin>>mon>>date;
        if(mon==0&&date==0)break;
        if(a[mon][date]==0)cout<<"Monday\n";
        else if(a[mon][date]==1)cout<<"Tuesday\n";
        else if(a[mon][date]==2)cout<<"Wednesday\n";
        else if(a[mon][date]==3)cout<<"Thursday\n";
        else if(a[mon][date]==4)cout<<"Friday\n";
        else if(a[mon][date]==5)cout<<"Saturday\n";
        else cout<<"Sunday\n";
    }

}

C++: //2004??´???366??\ /1/1 Thursday

#include <cstdio>

using namespace std;

void today(int mon, int day);

int main()
{
	int mon, day;
	
	while (1){
		scanf("%d %d", &mon, &day);
		
		if (day == 0){
			break;
		}
		
		today(mon, day);
	}
	
	return (0);
}

void today(int mon, int day)
{
	int tmp = 0;
	
	for (int i = 1; i < mon; i++){
		if (mon == 4 || mon == 6 || mon == 9 || mon == 11){
			tmp += 30;
		}
		else if (mon == 28){
			tmp += 29;
		}
		else {
			tmp += 31;
		}
	}
	
	switch ((tmp + day) % 7){
	  case 0:
	    puts("Wednesday");
		break;
		
	  case 1:
	    puts("Thursday");
		break;
		
	  case 2:
	    puts("Friday");
		break;
		
	  case 3:
	    puts("Saturday");
		break;
		
	  case 4:
	    puts("Sunday");
		break;
		
	  case 5:
	    puts("Monday");
		break;
		
	  case 6:
	    puts("Tuesday");
		break;
	}
}

C++: #include <iostream>
#include <string>
#include <map>
#include <utility>
using namespace std;
map<pair<int,int>,string> mp;
string s[7]={"Monday","Tuesday","Wendnesday","Thursday","Fryday","Saturday","Sunday"};
int main(){
	int cnt=3;
	for(int i=1;i<=12;i++){
		int days;
		if(i==2)	days=29;
		if(i&1) 	days=(i<=7?31:30);
		else 		days=(i<=7?30:31);
		for(int j=1;j<=days;j++){
			mp[make_pair(i,j)]=s[cnt++];
			cnt%=7;
		}
	}
	int m,d;
	while(true){
		cin>>m>>d;
		if(m==0)	return 0;
		cout<<mp[make_pair(m,d)]<<endl;
	}
	return 0;
}