import java.util.Scanner;
public class Demo01 {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int month=in.nextInt();
print(month);
in.close();
}
public static int day(int i){
int k=-1;
switch (i){
case 1: case 3: case 5: case 7: case 8: case 10: case 12:k=31;break;
case 4: case 6: case 9: case 11:k=30;break;
case 2:k=29;break;
default:break;
}
return k;
}
public static void print(int month){
int sum=3;
int k=day(month);
for (int j = 1; j < month; j++)
sum+=day(j);
int s=sum%7;
System.out.println("*****2020年"+month+"月份*****");
System.out.printf("%4s%4s%4s%4s%4s%4s%4s","日","一","二","三","四","五","六");
System.out.println();
int n=1;
for (int i = 0; i < s; i++)
System.out.printf("%3s"," ");
for (;s<7;s++){
System.out.printf("%3d",n);
n++;
}
System.out.println();
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 7; j++) {
System.out.printf("%3d",n);
n++;
if (n>k)break;
}
System.out.println();
}
}
}