s = input().strip()

x = ""

for i in range(len(s)):

    a = s[i]

    if a!="B":

        x += s[i]

    elif len(x)>0:

        x = x[:-1]

print(x)
s = input().strip()

x = ""

cur = 0

for i in range(len(s)):

    if s[i]=="0":

        x += "0"

        cur += 1

    elif s[i]=="1":

        x += "1"

        cur += 1

    else:

        if cur>0:

            x = x[:-1]

            cur -= 1

print(x)
s = input().strip()
x = ""
for i in range(len(s)):
    a = s[i]
    if a != "B":
        x += s[i]
    elif len(x) > 0:
        x = x[:-1]
print(x)

s = input().strip()
x = ""
cur = 0
for i in range(len(s)):
    if s[i] == "0":
        x += "0"
        cur += 1
    elif s[i] == "1":
        x += "1"
        cur += 1
    else:
        if cur > 0:
            x = x[:-1]
            cur -= 1
print(x)

+cur = 0 -    a = s[i] -    if a != "B": -        x += s[i] -    elif len(x) > 0: -        x = x[:-1] +    if s[i] == "0": +        x += "0" +        cur += 1 +    elif s[i] == "1": +        x += "1" +        cur += 1 +    else: +        if cur > 0: +            x = x[:-1] +            cur -= 1