Go: package main

import (
        "fmt"
)

func main() {
        var weeks = []string{"Thursday",
                "Friday",
                "Saturday",
                "Sunday",
                "Monday",
                "Tuesday",
                "Wednesday"}

        for {
                var m, d int
                _, err := fmt.Scanf("%d %d", &m, &d)
                if err != nil || m + d == 0 {
                        break
                }
                var days int

                for {
                        lm, ld := getLastDay(m, d)
                        if lm + ld == 0 {
                                break
                        }
                        days++
                        m = lm
                        d = ld
                }
                fmt.Println(weeks[days%7])
        }
}

func getLastDay(m int, d int) (lm int, ld int) {
        if m == 1 && d == 1 {
                return 0, 0
        }

        if d > 1 {
                return m, d-1
        } else {
                if m == 3 {
                        return m-1, 29
                }
                if m == 3 || m == 5 || m == 7 || m == 10 || m == 12 {
                        return m-1, 30
                } else {
                        return m-1, 31
                }
        }
}

C++: #include<iostream>
using namespace std;
int s[]={0,0,31,60,91,121,152,182,213,244,274,305,335},a,b;
string t[]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
main()
{
	while(cin>>a>>b,a)cout<<t[(s[a]+b)%7]<<endl;
}

C++: #include<iostream>
using namespace std;
int main(){
  int tuki[13]={0,0,31,60,91,121,152,182,213,244,274,305,335};
  string cal[400];
  cal[1]="Thursday";cal[2]="Friday";cal[3]="Saturday";cal[4]="Sunday";
  cal[5]="Monday";cal[6]="Tuesday";cal[7]="Wednesday";
  for(int i=1;i<=366;i++)
    cal[i+7]=cal[i];
  int a,b;
  while(cin>>a>>b,a+b)
    cout<<cal[tuki[a]+b]<<endl;
  return 0;
}

C++: //31,29,31,30,31,30,31,31,30,31,30,31//
#include <iostream>
using namespace std;
int main(){
    int i,j,d,m;
    while(cin>>m>>d){
        if(m==0&&d==0)break;
        if(m==1){
            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;
        }
        if(m==2){
            d=d+31;
            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;
        }
        if(m==3){
            d=d+60;
            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;
        }
        if(m==4){
            d=d+91;
            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;
        }
        if(m==5){
            d=d+121;
            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;
        }
        if(m==6){
            d=d+151;
            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;
        }
        if(m==7){
            d=d+181;
            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;
        }
        if(m==8){
            d=d+212;
            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;
        }
        if(m==9){
            d=d+243;
            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;
        }
        if(m==10){
            d=d+273;
            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;
        }
        if(m==11){
            d=d+304;
            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;
        }
        if(m==12){
            d=d+334;
            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<iostream>
using namespace std;

int main(){

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

  while(cin >> n >> m, n, m){

    d = 0;

    for(int i=0;i<n-1;i++) d = a[i] + d;
 
    d = d + m;

    while(d > 6) d -= 7;
   
    if(d == 5) cout << "Monday" << endl;
    else if(d == 5) cout << "Tuesday" << endl;
    else if(d == 0) cout << "Wednesday" << endl;
    else if(d == 1) cout << "Thursday" << endl;
    else if(d == 2) cout << "Friday" << endl;
    else if(d == 3) cout << "Saturday" << endl;
    else if(d == 4) cout << "Sunday" << endl;

  }
}

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

int main(){
  int m,d;
  int M[]={0,31,29,31,30,31,30,31,31,30,31,30,31};

  while(cin>>m>>d){
    if(m==0)break;
    int day=2;
    for(int i=m-1;i>0;i--){
      day+=M[i];
    }
    day+=d;
    if(day%7==0)cout<<"Monday"<<endl;
    if(day%7==1)cout<<"Tuesday"<<endl;
    if(day%7==2)cout<<"Wednesday"<<endl;
    if(day%7==3)cout<<"Thursday"<<endl;
    if(day%7==4)cout<<"Friday"<<endl;
    if(day%7==5)cout<<"Saturday"<<endl;
    if(day%7==6)cout<<"Sunday"<<endl;
  }
  return 0;
}