Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
hanten = True
for i in range(q):
    l = input().split()
    if l[0] == "1":
        hanten = not hanten
    else:
        if l[1] == "1":
            if hanten:
                s = l[2] + s
            else:
                s = s + l[2]
        else:
            if hanten:
                s = s + l[2]
            else:
                s = l[2] + s
 
if hanten == False:
    print(s[::-1])
else:
    print(s)

Fixed submission:
s = input()
q = int(input())
hanten = True
atm = ""
kts = ""
for i in range(q):
    l = input().split()
    if l[0] == "1":
        hanten = not hanten
    else:
        if l[1] == "1":
            if hanten:
                atm = l[2] + atm
            else:
                kts = kts + l[2]
        else:
            if hanten:
                kts = kts + l[2]
            else:
                atm = l[2] + atm

ans = atm + s + kts
if hanten == False:
    print(ans[::-1])
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
hanten = True
atm = ""
kts = ""
for i in range(q):
    l = input().split()
    if l[0] == "1":
        hanten = not hanten
    else:
        if l[1] == "1":
            if hanten:
                atm = l[2] + atm
            else:
                kts = kts + l[2]
        else:
            if hanten:
                kts = kts + l[2]
            else:
                atm = l[2] + atm

ans = atm + s + kts
if hanten == False:
    print(ans[::-1])
else:
    print(ans)

Fixed submission:
s = input()
q = int(input())
hanten = True
atm = ""
kts = ""
for i in range(q):
    l = input().split()
    if l[0] == "1":
        hanten = not hanten
    else:
        if l[1] == "1":
            if hanten:
                atm = l[2] + atm
            else:
                kts = kts + l[2]
        else:
            if hanten:
                kts = kts + l[2]
            else:
                atm = l[2] + atm

ans = atm + s + kts
if hanten == False:
    print(ans[::-1])
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
hanten = True
atm = ""
kts = ""
for i in range(q):
    l = input().split()
    if l[0] == "1":
        hanten = not hanten
    else:
        if l[1] == "1":
            if hanten == True:
                atm = l[2] + atm
            else:
                kts = kts + l[2]
        else:
            if hanten == True:
                kts = kts + l[2]
            else:
                atm = l[2] + atm

ans = atm + s + kts
if hanten == False:
    print(ans[::-1])
else:
    print(ans)

Fixed submission:
s = input()
q = int(input())
hanten = True
atm = ""
kts = ""
for i in range(q):
    l = input().split()
    if l[0] == "1":
        hanten = not hanten
    else:
        if l[1] == "1":
            if hanten:
                atm = l[2] + atm
            else:
                kts = kts + l[2]
        else:
            if hanten:
                kts = kts + l[2]
            else:
                atm = l[2] + atm

ans = atm + s + kts
if hanten == False:
    print(ans[::-1])
else:
    print(ans)

Buggy python submission (verdict: Runtime Error):
s = input()
q = int(input())
hanten = True
atm = ""
kts = ""
for i in range(q):
    l = input().split()
    if l[0] == "1":
        hanten = not hanten
    else:
        if l[1] == "1":
            if hanten == True:
                atm = l[2] + atm
            else:
                kts = kts + l[2]
        else:
            if hanten == True:
                kts = kts + l[2]
            else:
                atm = l[2] + atm

ans = atn + s + kts
if hanten == False:
    print(ans[::-1])
else:
    print(ans)

Fixed submission:
s = input()
q = int(input())
hanten = True
atm = ""
kts = ""
for i in range(q):
    l = input().split()
    if l[0] == "1":
        hanten = not hanten
    else:
        if l[1] == "1":
            if hanten:
                atm = l[2] + atm
            else:
                kts = kts + l[2]
        else:
            if hanten:
                kts = kts + l[2]
            else:
                atm = l[2] + atm

ans = atm + s + kts
if hanten == False:
    print(ans[::-1])
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
hanten = True
for i in range(q):
    l = input().split()
    if l[0] == "1":
        hanten = not hanten
    else:
        if l[1] == "1":
            if hanten == True:
                s = l[2] + s
            else:
                s = s + l[2]
        else:
            if hanten == True:
                s = s + l[2]
            else:
                s = l[2] + s

if hanten == False:
    print(s[::-1])
else:
    print(s)

Fixed submission:
s = input()
q = int(input())
hanten = True
atm = ""
kts = ""
for i in range(q):
    l = input().split()
    if l[0] == "1":
        hanten = not hanten
    else:
        if l[1] == "1":
            if hanten:
                atm = l[2] + atm
            else:
                kts = kts + l[2]
        else:
            if hanten:
                kts = kts + l[2]
            else:
                atm = l[2] + atm

ans = atm + s + kts
if hanten == False:
    print(ans[::-1])
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
hanten = 0
check = 0
for i in range(q):
    l = tuple(map(str, input().split()))
    if l[0] == "1":
        hanten += 1
        check += 1
    else:
        if l[1] == "1":
            if check%2 == 0:
                s = l[2] + s
            else:
                s = s + l[2]
        else:
            if check%2 == 0:
                s = s + l[2]
            else:
                s = l[2] + s

if hanten%2 == 1:
    s = s[::-1]

print(s)

Fixed submission:
s = input()
q = int(input())
hanten = True
atm = ""
kts = ""
for i in range(q):
    l = input().split()
    if l[0] == "1":
        hanten = not hanten
    else:
        if l[1] == "1":
            if hanten:
                atm = l[2] + atm
            else:
                kts = kts + l[2]
        else:
            if hanten:
                kts = kts + l[2]
            else:
                atm = l[2] + atm

ans = atm + s + kts
if hanten == False:
    print(ans[::-1])
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
hanten = 0
check = 0
for i in range(q):
    l = list(map(str, input().split()))
    if l[0] == "1":
        hanten += 1
        check += 1
    else:
        if l[1] == "1":
            if check%2 == 0:
                s = l[2] + s
            else:
                s = s + l[2]
        else:
            if check%2 == 0:
                s = s + l[2]
            else:
                s = l[2] + s

if hanten%2 == 1:
    s = s[::-1]

print(s)

Fixed submission:
s = input()
q = int(input())
hanten = True
atm = ""
kts = ""
for i in range(q):
    l = input().split()
    if l[0] == "1":
        hanten = not hanten
    else:
        if l[1] == "1":
            if hanten:
                atm = l[2] + atm
            else:
                kts = kts + l[2]
        else:
            if hanten:
                kts = kts + l[2]
            else:
                atm = l[2] + atm

ans = atm + s + kts
if hanten == False:
    print(ans[::-1])
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
hanten = 0
check = 0
for i in range(q):
    l = list(map(str, input().split()))
    if l[0] == "1":
        hanten += 1
    else:
        if l[1] == "1":
            if hanten%2 == 0:
                s = l[2] + s
            else:
                s = s + l[2]
        else:
            if hanten%2 == 0:
                s = s + l[2]
            else:
                s = l[2] + s
 
if hanten%2 == 1:
    s = s[::-1]
 
print(s)

Fixed submission:
s = input()
q = int(input())
hanten = True
atm = ""
kts = ""
for i in range(q):
    l = input().split()
    if l[0] == "1":
        hanten = not hanten
    else:
        if l[1] == "1":
            if hanten:
                atm = l[2] + atm
            else:
                kts = kts + l[2]
        else:
            if hanten:
                kts = kts + l[2]
            else:
                atm = l[2] + atm

ans = atm + s + kts
if hanten == False:
    print(ans[::-1])
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
hanten = 0
check = 0
for i in range(q):
    l = list(map(str, input().split()))
    if l[0] == "1":
        hanten += 1
        check += 1
    else:
        if l[1] == "1":
            if check%2 == 0:
                s = l[2] + s
            else:
                s = s + l[2]
        else:
            if check%2 == 0:
                s = s + l[2]
            else:
                s = l[2] + s

if hanten%2 == 1:
    s = s[::-1]

print(s)

Fixed submission:
s = input()
q = int(input())
hanten = True
atm = ""
kts = ""
for i in range(q):
    l = input().split()
    if l[0] == "1":
        hanten = not hanten
    else:
        if l[1] == "1":
            if hanten:
                atm = l[2] + atm
            else:
                kts = kts + l[2]
        else:
            if hanten:
                kts = kts + l[2]
            else:
                atm = l[2] + atm

ans = atm + s + kts
if hanten == False:
    print(ans[::-1])
else:
    print(ans)