import sys
def pad(markdown):
cells = [[cell.strip() for cell in line.split('|')] for line in markdown.splitlines()]
if all(all(x == '-' for x in cell) for cell in cells[1]):
del cells[1]
width = [max(len(item) for item in items) for items in zip(*cells)]
header = False
for line in cells:
formatted = []
for idx, col in enumerate(line):
formatted.append(f' %{-width[idx]-1}s' % line[idx])
print('|'.join(formatted).strip())
if not header:
print('|'.join([' ' + ''.ljust(w, '-') + ' ' for w in width]).strip())
header = True
pad(sys.stdin.read())
aW1wb3J0IHN5cwoKZGVmIHBhZChtYXJrZG93bik6CiAgY2VsbHMgPSBbW2NlbGwuc3RyaXAoKSBmb3IgY2VsbCBpbiBsaW5lLnNwbGl0KCd8JyldIGZvciBsaW5lIGluIG1hcmtkb3duLnNwbGl0bGluZXMoKV0KICBpZiBhbGwoYWxsKHggPT0gJy0nIGZvciB4IGluIGNlbGwpIGZvciBjZWxsIGluIGNlbGxzWzFdKToKICAgIGRlbCBjZWxsc1sxXQogIHdpZHRoID0gW21heChsZW4oaXRlbSkgZm9yIGl0ZW0gaW4gaXRlbXMpIGZvciBpdGVtcyBpbiB6aXAoKmNlbGxzKV0KICBoZWFkZXIgPSBGYWxzZQogIGZvciBsaW5lIGluIGNlbGxzOgogICAgZm9ybWF0dGVkID0gW10KICAgIGZvciBpZHgsIGNvbCBpbiBlbnVtZXJhdGUobGluZSk6CiAgICAgIGZvcm1hdHRlZC5hcHBlbmQoZicgJXstd2lkdGhbaWR4XS0xfXMnICUgbGluZVtpZHhdKQogICAgcHJpbnQoJ3wnLmpvaW4oZm9ybWF0dGVkKS5zdHJpcCgpKQogICAgaWYgbm90IGhlYWRlcjoKICAgICAgcHJpbnQoJ3wnLmpvaW4oWycgJyArICcnLmxqdXN0KHcsICctJykgKyAnICcgZm9yIHcgaW4gd2lkdGhdKS5zdHJpcCgpKQogICAgICBoZWFkZXIgPSBUcnVlCgpwYWQoc3lzLnN0ZGluLnJlYWQoKSk=