public class test{
public static void main(String[]args){
int sum=0;
for(int year =1900;year<=2017;year++){
if(year%4==0&&year%100!=0||year%400==0){
sum=sum+366;
}else{
sum=sum+365;
}
}
for(int month=1;month<=8;month++){
if(month==2){
if(2018%4==0&&2018%100!=0||2018%400==0){
sum=sum+29;
}else{
sum=sum+28;
}
}else{
if (month==4||month==6||month==9||month==11){
sum=sum+30;
}else{
sum=sum+31;
}
}
}
sum=sum+1;
int weekday=sum%7;
System.out.println("日\t一\t二\t三\t四\t五\t六");
for(int i=1;i<=weekday;i++){
System.out.print("\t");
}
for(int i=1;i<=30;i++){
if(sum%7==6){
System.out.print(i+"\n");
}else{
System.out.print(i+"\t");
}
sum++;
}
}
}