// days.cpp : ÈÕÀúÎÊÌâ.
//

#include "stdafx.h"
#include <stdio.h>
#include <string.h>

int main()
{
	char week[7][10] = {"Saturday", "Sunday", "Monday", "Tuesday", 
					"Wednesday", "Thursday", "Friday"};
	int year[2] = {365, 366}; 
	int month[2][12] = {{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, {31, 29, 31, 
		30, 31, 30, 31, 31, 30, 31, 30, 31}};
	int leap_year;
	int y, m, dayofweek;
	int days;

	scanf("%d", &days);
	while (days != -1) {
       	dayofweek = days % 7;

		y = 2000;
		leap_year = 1;
		while(days >= year[leap_year]) {
			days -= year[leap_year];      
			y++;
		  	leap_year = (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;
		}

        m = 0;
		leap_year = (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;
		while(days >= month[ leap_year ][m]){
            days -= month[leap_year][m];      
            m++;
		}

		printf("%d-%d-%d %s\n",y,m+1,days+1, week[dayofweek]);

		scanf("%d", &days);
	}

	return 0;
}
