Buggy python submission (verdict: Time Limit Exceeded):
left = input()
q = int(input())
right = ""
flag = 0
for i in range(q) :
    t = input()
    if t == "1" :
        flag ^= 1
        continue
    t, f, c = t.split(" ")
    f = int(f)
    left = c*((flag+f)%2) + left
    right += c*((flag+f-1)%2)
if flag == 0 :
    print(left+right)
else :
    print(right[::-1]+left[::-1])

Fixed submission:
right = input()
Q = int(input())
flag = 0b1
left = ""
for i in range(Q):
    q = input()
    if q == "1":
        flag ^= 1
        continue
    m,f,c = q.split(" ")
    f = int(f)
    left += c*(1-flag)*(f-1)
    right += c*flag*(f-1)
    left += c*flag*(2-f)
    right += c*(1-flag)*(2-f)
if flag == 1:
    print(left[::-1]+right)
else:
    print(right[::-1]+left)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
flag = 0b0
for i in range(q) :
    t = input()
    if t == "1" :
        flag ^= 1
        continue
    t, f, c = t.split(" ")
    f = int(f)
    s = c*((flag+f)%2) + s + c*((flag+f+1)%2)
if flag == 0 :
    print(s)
else :
    print(s[::-1])

Fixed submission:
right = input()
Q = int(input())
flag = 0b1
left = ""
for i in range(Q):
    q = input()
    if q == "1":
        flag ^= 1
        continue
    m,f,c = q.split(" ")
    f = int(f)
    left += c*(1-flag)*(f-1)
    right += c*flag*(f-1)
    left += c*flag*(2-f)
    right += c*(1-flag)*(2-f)
if flag == 1:
    print(left[::-1]+right)
else:
    print(right[::-1]+left)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
flag = 0b0
for i in range(q) :
    t = input()
    if t == "1" :
        flag ^= 1
        continue
    if (int(t[2]) - flag) == 1 :
        s = t[4] + s
    else :
        s = s + t[4]
if flag == 0 :
    print(s)
else :
    print(s[::-1])

Fixed submission:
right = input()
Q = int(input())
flag = 0b1
left = ""
for i in range(Q):
    q = input()
    if q == "1":
        flag ^= 1
        continue
    m,f,c = q.split(" ")
    f = int(f)
    left += c*(1-flag)*(f-1)
    right += c*flag*(f-1)
    left += c*flag*(2-f)
    right += c*(1-flag)*(2-f)
if flag == 1:
    print(left[::-1]+right)
else:
    print(right[::-1]+left)

Buggy python submission (verdict: Runtime Error):
s = input()
q = int(input())
flag = 0b0
for i in range(q) :
    t = input()
    if t == 1 :
        flag ^= 1
        continue
    if (int(t[2]) - flag) == 1 :
        s = t[4] + s
    else :
        s = s + t[4]
if flag == 0 :
    print(s)
else :
    print(s[::-1])

Fixed submission:
right = input()
Q = int(input())
flag = 0b1
left = ""
for i in range(Q):
    q = input()
    if q == "1":
        flag ^= 1
        continue
    m,f,c = q.split(" ")
    f = int(f)
    left += c*(1-flag)*(f-1)
    right += c*flag*(f-1)
    left += c*flag*(2-f)
    right += c*(1-flag)*(2-f)
if flag == 1:
    print(left[::-1]+right)
else:
    print(right[::-1]+left)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
flag = 0b0
for i in range(q) :
    t = input()
    if len(t) == 5 :
        if (int(t[2]) - flag) == 1 :
            s = t[4] + s
        else :
            s = s + t[4]
    else :
        flag ^= 1
if flag == 0 :
    print(s)
else :
    print(s[::-1])

Fixed submission:
right = input()
Q = int(input())
flag = 0b1
left = ""
for i in range(Q):
    q = input()
    if q == "1":
        flag ^= 1
        continue
    m,f,c = q.split(" ")
    f = int(f)
    left += c*(1-flag)*(f-1)
    right += c*flag*(f-1)
    left += c*flag*(2-f)
    right += c*(1-flag)*(2-f)
if flag == 1:
    print(left[::-1]+right)
else:
    print(right[::-1]+left)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
for i in range(q) :
    t = input()
    if len(t) == 5 :
        f = t[2]
        c = t[4]
        if f == "1" :
            s = c + s
        else :
            s = s + c
    else :
        s = s[::-1]
print(s)

Fixed submission:
right = input()
Q = int(input())
flag = 0b1
left = ""
for i in range(Q):
    q = input()
    if q == "1":
        flag ^= 1
        continue
    m,f,c = q.split(" ")
    f = int(f)
    left += c*(1-flag)*(f-1)
    right += c*flag*(f-1)
    left += c*flag*(2-f)
    right += c*(1-flag)*(2-f)
if flag == 1:
    print(left[::-1]+right)
else:
    print(right[::-1]+left)