#t119. 日历制作

日历制作

Calendar Making

Problem Description

Little A wants to make a calendar for each month of the year 20252025. 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 mm, indicating that you should print the calendar of the mm-th month of 20252025 in the required format.

Output Format

Output several lines representing the calendar of the mm-th month of 20252025.

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 99, 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 3030 days in total, so there are 55 lines of dates, where the last line contains only 2929 and 3030. Each output column is strictly aligned with the weekday abbreviations.

Constraints

For all test cases, 1≤m≤121 \leq m \leq 12.