import java.text.DecimalFormat;
import java.util.Scanner;
public class Date {
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int month,day,c,Y,W,i,j,w;
int t[]={31,0,31,30,31,30,31,31,30,31,30,31};
int year=scan.nextInt();
if(year%4==0&&year%100!=0||year%400==0)
t[1]=29;
else
t[1]=28;
for(month=1;month<=12;month++){
if(month<3){
c=((int)(year-1)/100);
Y=(year-1)-((int)((year-1)/100))*100;
w=((int)(c/4))-2*c+Y+((int)(Y/4))+((int)(26*(month+12+1)/10));
W=w%7;
}
else{
c=((int)(year/100));
Y=year-((int)(year/100))*100;
w=((int)(c/4))-2*c+Y+((int)(Y/4))+((int)(26*(month+1)/10));
W=w%7;
}
i=(W+7-1)%7;
System.out.println("\n"+month);
System.out.println("*Mon Tue Wed Thu Fri Sat Sun");
for(j=1;j<=(W+7-1)%7;j++)
System.out.print(" ");
for(day=1;day<=t[month-1];day++){
i++;
DecimalFormat format = new DecimalFormat(" 00");
System.out.print(format.format(day));
if(i%7==0)
System.out.println();
}
}
scan.close();
}
}
import java.util.Scanner;
public class Date {
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int month,day,c,Y,W,i,j,w;
int t[]={31,0,31,30,31,30,31,31,30,31,30,31};
int year=scan.nextInt();
if(year%4==0&&year%100!=0||year%400==0)
t[1]=29;
else
t[1]=28;
for(month=1;month<=12;month++){
if(month<3){
c=((int)(year-1)/100);
Y=(year-1)-((int)((year-1)/100))*100;
w=((int)(c/4))-2*c+Y+((int)(Y/4))+((int)(26*(month+12+1)/10));
W=w%7;
}
else{
c=((int)(year/100));
Y=year-((int)(year/100))*100;
w=((int)(c/4))-2*c+Y+((int)(Y/4))+((int)(26*(month+1)/10));
W=w%7;
}
i=(W+7-1)%7;
System.out.println("\n"+month);
System.out.println("*Mon Tue Wed Thu Fri Sat Sun");
for(j=1;j<=(W+7-1)%7;j++)
System.out.print(" ");
for(day=1;day<=t[month-1];day++){
i++;
DecimalFormat format = new DecimalFormat(" 00");
System.out.print(format.format(day));
if(i%7==0)
System.out.println();
}
}
scan.close();
}
}