1134. 小日历

单点时限: 5.0 sec

内存限制: 256 MB

It is April Fool’s Day today, lying and kidding are all over the world. But still, it is April Fool’s Day, so things should be simpler to fit the fools. On this special day, laughing at other people is so old a way to prove he is a fool, so that partychen wants to have a change. He hopes this day to become a day when one will kindly help another no matter how stupid the problem is.

One common thing is that some people cannot tell the exact date, so here the task is easy. Just make a simple calendar for them.

First of all, one should get the correct information when he needs to make anything. Fortunately, here, all the information is available. Do not forget, it is April Fool’s Day, and even a fool can manage to do anything on this day. You should show your ability to the real fools. So here is the table of some definitions.

  • Leap Year. A leap year is a year that has one extra day in February. More precisely, a leap year is a year with its year number divided exactly by four but not divided exactly by one hundred or its year number divided exactly by four hundred.

  • Months. The name of months are January, February, March, April, May, June, July, August, September, October, November, and December. We use the first four letters(except for May) to stand for a month for short.

  • Weekdays. The name of weekdays are Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday. We use the first three letters to stand for a day for short.

  • Calendar. A month-calendar should contain the name of the month and year and every day with the weeks. That’s all, but nothing can be omitted.

Then the goal is clear, that is, to make a calendar simple. The key word today is simple. So here are rules for simple.

  • Format. The first line should contain the month name and the year number, a line of subtraction signs follows that. Then comes the name of weekdays, and again a line of subtraction signs follows. Days are the main part, and a line of equal signs is the symbol of the end.

  • Line number. The main part should be exactly five lines, with the other parts just one line. If the main part can only fill four lines, live an extra blank line. Or if the main part needs six lines, move the last line to the first, which will cause something looked like 31 or(and) 30 before 1. You may think it is not simple, but to the line number, it is the same, so it is to some standards, simple.

  • Weekdays. Number of days must right below the right weekdays.

  • Spaces. Any extra spaces at the end of line is not believed simple, so pay special attention to that.

The last thing is the details, which is the most boring thing but most important. You should not be afraid of these rules, they are for fools. To be a clearer man, just see the samples.

  • The year number is exactly four digits.

  • The month name must be just four letters, except for May.

  • The weekday name must be just three letters, no exception.

  • Februay has 29 days in leap years, and one day less in other years.

Finally, here we go. Happy April Fool’s Day!

输入格式

There are multiple cases, for fools can be confused in many cases.

Each case contains two integers y(2007 <= y <= 9999) and m(1 <= m <= 12). You should not consider the first three months of 2007 either, because the help is available only from today on. History is not in our consideration.

Here y is the year number and m is the month number with 1 standing for January, 2 standing for February, and so on.

There is no special signal for the end, so please process to the end of the input.

输出格式

There should be several lines for one input case.

  • The first line is the month name, a comma, a blank, and the year number.

  • The second line, a line of l subtraction signs.

  • The next line, a line containing all the weekday names starting from Sunday, seperated by just one blank between adjacent items.

  • Then the following line, a line of l subtraction signs.

  • Then the main body of the calendar, with each day right justified to its weekday name.

  • The last line is a line of l equal signs.

The above mentioned l is the maximum location of the last charater of other lines.

The last thing to say is that you should also add a blank line between adjacent cases.

样例

Input
2007 4
2007 5
2007 12
2009 2
2014 2
Output
Apri, 2007
Input
Sun Mon Tue Wed Thu Fri Sat
Output
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
===========================
May, 2007
Input
Sun Mon Tue Wed Thu Fri Sat
Output
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 31
===========================
Dece, 2007
Input
Sun Mon Tue Wed Thu Fri Sat
Output
30 31 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
===========================
Febr, 2009
Input
Sun Mon Tue Wed Thu Fri Sat
Output
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
===========================
Febr, 2014
Input
Sun Mon Tue Wed Thu Fri Sat
Output
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
===========================
输出的例子如果是两个空行看作是一个空行(即空行数减一)

9 人解决,22 人已尝试。

15 份提交通过,共有 99 份提交。

7.5 EMB 奖励。

创建: 15 年,7 月前.

修改: 5 年,3 月前.

最后提交: 2 年前.

来源: partychen

题目标签