Almost every text editor has a built-in function of center text alignment. The developers of the popular in Berland text editor «Textpad» decided to introduce this functionality into the fourth release of the product.

You are to implement the alignment in the shortest possible time. Good luck!
The input file consists of one or more lines, each of the lines contains Latin letters, digits and/or spaces. The lines cannot start or end with a space. It is guaranteed that at least one of the lines has positive length. The length of each line and the total amount of the lines do not exceed 1000.
import sys

def centrify(lines, max_len):
	left_add = 0
	right_add = 1
	for line in lines:
		if len(line) == 0:
			yield ' ' * max_len
			continue
		if len(line) == max_len:
			yield line
			continue
		reserve = max_len - len(line)
		half = reserve // 2
		if reserve % 2 != 0:
			yield ' ' * (half + left_add) + line + ' ' * (half + right_add)
			left_add = 1 - left_add
			right_add = 1 - right_add
			continue
		yield ' ' * half + line + ' ' * half


def zvezdify(lines, max_len):
	yield '*' * (max_len + 2)
	for line in lines:
		yield '*' + line + '*'
	yield '*' * (max_len + 2)


def solve(lines):
	lines = [l.rstrip() for l in lines]
	max_len = max(len(l) for l in lines)
	return '\n'.join(zvezdify(centrify(lines, max_len), max_len))


def test():
	lines = ['a', '3n3', '']
	# lines = ['qqq', 's']
	max_len = max(len(l) for l in lines)
	centered = list(centrify(lines, max_len))
	print(centered)
	print(list(zvezdify(centered, max_len)))


def test2():
	print(solve(['4f43', 'e', '', '322']))
	print(solve(['4', 'e', '', '322', 'ab', 'bc', 'de']))

if __name__ == '__main__':
	# test2()
	lines = sys.stdin.readlines()
	print(solve(lines))
