t=""

for x in eval(input()):

  if x=="B":

    t=t[:-1]

  else:

    t+=x

print(t)
t=[]

for i in eval(input()):

  if i=="B":

    try:t.pop()

    except:pass

  else:

    t.append(i)

print(("".join(t)))
t = ""
for x in eval(input()):
    if x == "B":
        t = t[:-1]
    else:
        t += x
print(t)

t = []
for i in eval(input()):
    if i == "B":
        try:
            t.pop()
        except:
            pass
    else:
        t.append(i)
print(("".join(t)))

-t = "" -for x in eval(input()): -    if x == "B": -        t = t[:-1] +t = [] +for i in eval(input()): +    if i == "B": +        try: +            t.pop() +        except: +            pass -        t += x -print(t) +        t.append(i) +print(("".join(t)))