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
from math import floor, ceil

text = []
for line in sys.stdin:
  text.append(line.strip())

max_len = max(map(lambda x: len(x), text))
new_lines = []
new_lines.append("*" * (max_len+2))
left = True
for old_line in text:
  spaces_to_add = max_len - len(old_line)
  if spaces_to_add % 2 == 1:
    if left:
      left_spaces_to_add = floor(spaces_to_add/2)
      right_spaces_to_add = ceil(spaces_to_add/2)
      left = False
    else:
      left_spaces_to_add = ceil(spaces_to_add/2)
      right_spaces_to_add = floor(spaces_to_add/2)
      left = True
  else:
    left_spaces_to_add = int(spaces_to_add/2)
    right_spaces_to_add = left_spaces_to_add
  new_line = "*" + " " * left_spaces_to_add + old_line + " " * right_spaces_to_add + "*"
  new_lines.append(new_line)

new_lines.append("*" * (max_len+2))
print('\n'.join(new_lines))
	  			 	  				 	   	 	  						