#t119. 日历制作
日历制作
Calendar Making
Problem Description
Little A wants to make a calendar for each month of the year . He hopes you can write a program that prints the calendar of a given month in the required format.
Specifically, the first line must print MON TUE WED THU FRI SAT SUN, representing Monday through Sunday. In the following lines, the dates of that month are printed in order; the units digit of each date must be aligned with the last letter of the corresponding weekday abbreviation. For example, September 1, 2025 is a Monday, so when printing September's calendar, the units digit 1 of the 1st must be aligned with the last letter N of MON. The printed calendar for September looks like this:
MON TUE WED THU FRI SAT SUN
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Can you help Little A make the calendar?
Input Format
One line, a positive integer , indicating that you should print the calendar of the -th month of in the required format.
Output Format
Output several lines representing the calendar of the -th month of .
Sample Input 1
9
Sample Input 2
6
Sample Output 1
MON TUE WED THU FRI SAT SUN
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Sample Output 2
MON TUE WED THU FRI SAT SUN
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
Sample Explanation
The input is , meaning we should print the calendar of September 2025. Since September 1, 2025 is a Monday, the first line starts with 1 under Monday, and the following dates are arranged to the right, one week per line. September has days in total, so there are lines of dates, where the last line contains only and . Each output column is strictly aligned with the weekday abbreviations.
Constraints
For all test cases, .