Under construction

Still being built. Things may change

Kalendar

Time limit1sMemory limit1024 MB

Summary
Given the day count n and the starting weekday d, the task prints a 7-column month calendar framed with '+', '-', and '|' characters.
Level

Easy2 of 10

Topics
Simulation, Implementation
Solved
No attempts yet

Problem

Magdalena likes calendars, and she makes her own calendar for each month.

Each day of the month is written with exactly three characters.

  • If the day number has one digit, it is written as '..X'. For example, 7 is written as '..7'.
  • If the day number has two digits, it is written as '.XY'. For example, 17 is written as '.17'.

Each row of the calendar is a week of 7 days. If a week does not have all 7 days (because the month does not start on Monday, or does not end on Sunday), the missing days are replaced with '...'.

Magdalena decorates the calendar this way: she fills the upper and lower sides with '-' (ASCII 45), the left and right sides with '|' (ASCII 124), and the corners with '+' (ASCII 43).

For example, a month with 31 days that starts on Wednesday looks like this:

+---------------------+
|........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......|
+---------------------+

Input

The first and only line contains two integers n and d (1 <= n <= 99, 1 <= d <= 7). n is the number of days in the month, and d is the day of the week on which the month starts. For example, d = 1 means the month starts on Monday, and d = 5 means it starts on Friday.

Output

Print Magdalena's calendar.

Hint

In the second sample, the month has only one day, but the calendar still uses seven day cells per row.

Examples3

  1. Example 1

    Input
    31 3
    
    Expected 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......|
    +---------------------+
    
  2. Example 2

    Input
    1 5
    
    Expected output
    +---------------------+
    |..............1......|
    +---------------------+
    
  3. Example 3

    Input
    28 7
    
    Expected 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...|
    +---------------------+