Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
n = int(input())
Q = [list(map(str, input().split())) for _ in range(n)]
cnt = 0
for q in Q:
    if q[0] == "1":
        cnt += 1
    elif q[0] == "2":
        if (int(q[1])+cnt)%2 == 1:
            S = q[2] + S
        else:
            S = S + q[2]

if cnt%2==1:
    S = list(S)
    S.reverse()
print("".join(S))

Fixed submission:
S = str(input())
n = int(input())
Q = [list(map(str, input().split())) for _ in range(n)]
cnt = 0
s_pre = ""
s_pro = ""
for q in Q:
    if q[0] == "1":
        cnt += 1
    else:
        if (int(q[1])+cnt)%2 == 1:
#             S = q[2] + S
            s_pre = q[2] + s_pre
        else:
            s_pro = s_pro + q[2]
#             S = S + q[2]

S = s_pre + S + s_pro
if cnt%2==1:
    S = list(S)
    S.reverse()
print("".join(S))

Buggy python submission (verdict: Runtime Error):
S = str(input())
n = int(input())
Q = [list(map(str, input().split())) for _ in range(n)]
cnt = 0
# for q in Q:
#     if q[0] == "1":
#         cnt += 1
# #         S.reverse()
#     elif q[0] == "2":
#         if (int(q[1])+cnt)%2 == 1:
#             S.insert(0,q[2])
#         else:
#             S.append(q[2])
for q in Q:
    if q[0] == "1":
        cnt += 1
    elif q[0] == "2":
        if (int(q[1])+cnt)%2 == 1:
            S = q[2] + S
        else:
            S = S + q[2]

if cnt%2==1:
    S.reverse()
print("".join(S))

Fixed submission:
S = str(input())
n = int(input())
Q = [list(map(str, input().split())) for _ in range(n)]
cnt = 0
s_pre = ""
s_pro = ""
for q in Q:
    if q[0] == "1":
        cnt += 1
    else:
        if (int(q[1])+cnt)%2 == 1:
#             S = q[2] + S
            s_pre = q[2] + s_pre
        else:
            s_pro = s_pro + q[2]
#             S = S + q[2]

S = s_pre + S + s_pro
if cnt%2==1:
    S = list(S)
    S.reverse()
print("".join(S))

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
n = int(input())
Q = [list(map(str, input().split())) for _ in range(n)]
cnt = 0
for q in Q:
    if q[0] == "1":
        cnt += 1
#         S.reverse()
    elif q[0] == "2":
        if (int(q[1])+cnt)%2 == 1:
            S.insert(0,q[2])
        else:
            S.append(q[2])

if cnt%2==1:
    S.reverse()
print("".join(S))

Fixed submission:
S = str(input())
n = int(input())
Q = [list(map(str, input().split())) for _ in range(n)]
cnt = 0
s_pre = ""
s_pro = ""
for q in Q:
    if q[0] == "1":
        cnt += 1
    else:
        if (int(q[1])+cnt)%2 == 1:
#             S = q[2] + S
            s_pre = q[2] + s_pre
        else:
            s_pro = s_pro + q[2]
#             S = S + q[2]

S = s_pre + S + s_pro
if cnt%2==1:
    S = list(S)
    S.reverse()
print("".join(S))

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
n = int(input())
Q = [list(map(str, input().split())) for _ in range(n)]

for q in Q:
    if q[0] == "1":
        S.reverse()
    elif q[0] == "2":
        if q[1] == "1":
            S.insert(0,q[2])
        else:
            S.append(q[2])
print("".join(S))

Fixed submission:
S = str(input())
n = int(input())
Q = [list(map(str, input().split())) for _ in range(n)]
cnt = 0
s_pre = ""
s_pro = ""
for q in Q:
    if q[0] == "1":
        cnt += 1
    else:
        if (int(q[1])+cnt)%2 == 1:
#             S = q[2] + S
            s_pre = q[2] + s_pre
        else:
            s_pro = s_pro + q[2]
#             S = S + q[2]

S = s_pre + S + s_pro
if cnt%2==1:
    S = list(S)
    S.reverse()
print("".join(S))