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.
from sys import stdin
#bringing them closer left or right alternatively
#stdin...
def CF_5B():
    lines=[]
    for line in stdin.readlines():
        line=line.strip()
        lines.append(line)
    length=0
    for i in range(len(lines)):
        if len(lines[i])>length:
            length=len(lines[i])
        else:
            continue
    
    print('*'*(length+2))
    flag=0
    for i in range(len(lines)):
        if length%2==len(lines[i])%2:
            left=(length-len(lines[i]))//2
            right=(length-len(lines[i]))//2
        elif flag==0:
            left=(length-len(lines[i]))//2
            right=length-len(lines[i])-left
            flag=1
        else:
            right=(length-len(lines[i]))//2
            left=length-len(lines[i])-right
            flag=0
        print('*'+' '*left+lines[i]+' '*right+'*')
    print('*'*(length+2))
    return

CF_5B()
        
