from __future__ import print_function
from collections import defaultdict

cups = defaultdict(set)

def add():
    for y in sorted(cups, reverse=True):
        for x in sorted(cups[y]):
            if x+1 in cups[y] and (y+1 not in cups or x not in cups[y+1]):
                cups[y+1].add(x)
                return

    x = 0
    while True:
        if x not in cups[0]:
            cups[0].add(x)
            return

        x += 1

def remove():
    for y in sorted(cups, reverse=True):
        cups[y].remove(min(cups[y]))

        if not cups[y]:
            del cups[y]

        return

def print_cups():
    for y, row in sorted(cups.items(), reverse=True):
        print(" "*y + " ".join(" A"[x in row] for x in range(max(row)+1)))

instructions = ""

try:
    input = raw_input
except NameError:
    pass

while True:
    try:
        line = input()
        if not line: break
        instructions += line
        
    except EOFError:
        break

a = None
r = None

for c in [x for x in instructions if ' ' <= x <= '~']:
    if a is None or c == a:
        add()
        a = c

    elif r is None or c == r:
        remove()
        r = c

print_cups()