S = input()

a = []



for s in S:

  if s=="B":

    if a:

      a.pop()

  else:

    a.append(s)



print(*a,sep="")

a = ""



for s in eval(input()):

  if s=="B":

    a=a[:-1]

  else:

    a+=s



print(a)
S = input()
a = []
for s in S:
    if s == "B":
        if a:
            a.pop()
    else:
        a.append(s)
print(*a, sep="")

a = ""
for s in eval(input()):
    if s == "B":
        a = a[:-1]
    else:
        a += s
print(a)

-S = input() -a = [] -for s in S: +a = "" +for s in eval(input()): -        if a: -            a.pop() +        a = a[:-1] -        a.append(s) -print(*a, sep="") +        a += s +print(a)