import java.util.Scanner;
public class x{
public static void main(String[] args){
Scanner in=new Scanner(System.in);
System.out.println("请输入你要的年:");
int n = in.nextInt();
System.out.println("请输入你要的月:");
int y=in.nextInt();
int d=0;
for(int year=1900;year<n;year++){
if(year%4==0&&year%100!=0||year%400==0){
d=d+366;
}else{
d=d+365;
}
}
for(int month=1;month<y;month++){
if(month==2){
if(n%4==0&&n%100!=0||n%400==0){
d=d+29;
}else{
d=d+28;
}
}
if(month==4||month==6||month==9||month==11){
d=d+30;
}else{
d=d+31;
}
}
d=d+1;
int s=d%7;
System.out.println(s);
System.out.println("日\t一\t二\t三\t四\t五\t六");
for(int i=1;i<=s;i++){
System.out.print("\t");
}
for(int i=1; i<=31;i++){
if(d%7==6){
System.out.print(i+"\n");
}else{
System.out.print(i+"\t");
}
d=d+1;
}
}
}
public class x{
public static void main(String[] args){
Scanner in=new Scanner(System.in);
System.out.println("请输入你要的年:");
int n = in.nextInt();
System.out.println("请输入你要的月:");
int y=in.nextInt();
int d=0;
for(int year=1900;year<n;year++){
if(year%4==0&&year%100!=0||year%400==0){
d=d+366;
}else{
d=d+365;
}
}
for(int month=1;month<y;month++){
if(month==2){
if(n%4==0&&n%100!=0||n%400==0){
d=d+29;
}else{
d=d+28;
}
}
if(month==4||month==6||month==9||month==11){
d=d+30;
}else{
d=d+31;
}
}
d=d+1;
int s=d%7;
System.out.println(s);
System.out.println("日\t一\t二\t三\t四\t五\t六");
for(int i=1;i<=s;i++){
System.out.print("\t");
}
for(int i=1; i<=31;i++){
if(d%7==6){
System.out.print(i+"\n");
}else{
System.out.print(i+"\t");
}
d=d+1;
}
}
}