# Arup Guha
# 11/16/2024
# Solution to 2024 SER D1/D2 Problem: Welcome Sign

toks = input().split()
r = int(toks[0])
c = int(toks[1])

# Count of unequal rows.
uneq = 0

for i in range(r):

    # Get the string.
    s = input().strip()
    diff = c - len(s)

    # Unequal.
    if diff%2 != 0:

        # Calculate padding
        left = diff//2 + uneq
        right = diff - left

        # This is what we want.
        print(left*".",s,right*".", sep="")

        # Flip it.
        uneq = 1 - uneq

    # Easy case.
    else:
        print((diff//2)*".",s,(diff//2)*".", sep="")
        
