# @dvoiss:
# https://g...content-available-to-author-only...b.com/3347094

# For the reddit daily programmer challenge

# Challenge: http://w...content-available-to-author-only...t.com/r/dailyprogrammer/comments/y5svk/8132012_challenge_88_intermediate_printing_out_a/
# Solution: http://w...content-available-to-author-only...t.com/r/dailyprogrammer/comments/y5svk/8132012_challenge_88_intermediate_printing_out_a/c5soy7s

import calendar
separator_string = '+' + '-'*20 + '+'
def print_cal(month, year):
	month_days = [ '' if i == 0 else str(i) for i in calendar.Calendar(0).itermonthdays(year, month) ]

	print separator_string + '\n|' + str.center( calendar.month_name[month], 20 ) + '|\n' + separator_string
	print '|' + "".join(['{' + str(i) + ':<2}|' for i in range(0, 7) ]).format(*map(lambda x: x[0] + ' ', calendar.day_abbr))
	print separator_string
	print "".join([('|{' if j % 7 == 0 else '{') + str(i + j + (6 * i)) + ':<2}|'
		+ ('\n' if j % 7 == 6 and i != (len(month_days) / 7 - 1) else '') for i in range(0, len(month_days) / 7) for j in range(0, 7)]).format(*month_days)
	print separator_string


input = map(lambda x: int(x), raw_input().split(' '))
print_cal( input[0], input[1] )