a = ""



for s in eval(input()):

  if s=="B":

    if len(a)!=0:

      a=a[:-1]

  else:

    a+=s



print(a)
a = ""



for s in eval(input()):

  if s=="B":

    a=a[:-1]

  else:

    a+=s



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

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

-        if len(a) != 0: -            a = a[:-1] +        a = a[:-1]