Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

S = input()
Q = int(input())

query = []

for i in range(Q):
    query.append(input().split())


left = True
for i in query:
    if len(i) == 1:
        left = not left

    else:
        if i[1]=="1":
            if left:
                S = i[2]+S
            else:
                S += i[2]
        else:
            if left:
                S += i[2]
            else:
                S = i[2]+S

print(S) if left else print(S[::-1])


Fixed submission:
# coding: utf-8

S = input()
Q = int(input())

query = []

for i in range(Q):
    query.append(input().split())


bool = True
pre =''
suf =''

for i in query:
    if len(i) == 1:
        bool = not(bool)

    else:
        if i[1]=="1":
            if bool:
                pre = i[2]+pre
            else:
                suf += i[2]
        else:
            if bool:
                suf += i[2]
            else:
                pre = i[2]+pre

S = pre+ S +suf
print(S) if bool else print(S[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

S = input()
Q = int(input())
# print("S:{}".format(S))
# print("Q:{}".format(Q))
query = []

for i in range(Q):
    query.append(input().split())


# for i in query:
#     print(i)

# for i in query:
#     if len(i) == 1:
#         S = S[::-1]
#     else:
#         if i[1]=="1":
#             S = i[2]+S
#         else:
#             S += i[2]
# print(S)
left = True
for i in query:
    if len(i) == 1:
        left = not left
        # print(left)
    else:
        if i[1]=="1":
            if left:
                S = i[2]+S
            else:
                S += i[2]
        else:
            if left:
                S += i[2]
            else:
                S = i[2]+S

print(S) if left else print(S[::-1])


Fixed submission:
# coding: utf-8

S = input()
Q = int(input())

query = []

for i in range(Q):
    query.append(input().split())


bool = True
pre =''
suf =''

for i in query:
    if len(i) == 1:
        bool = not(bool)

    else:
        if i[1]=="1":
            if bool:
                pre = i[2]+pre
            else:
                suf += i[2]
        else:
            if bool:
                suf += i[2]
            else:
                pre = i[2]+pre

S = pre+ S +suf
print(S) if bool else print(S[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

S = input()
Q = int(input())
# print("S:{}".format(S))
# print("Q:{}".format(Q))
query = []

for i in range(Q):
    query.append(input().split())
# for i in query:
#     print(i)

# for i in query:
#     if len(i) == 1:
#         S = S[::-1]
#     else:
#         if i[1]=="1":
#             S = i[2]+S
#         else:
#             S += i[2]
# print(S)
left = True
for i in query:
    if len(i) == 1:
        left = not left
        # print(left)
    else:
        if i[1]=="1":
            if left:
                S = i[2]+S
            else:
                S += i[2]
        else:
            if left:
                S += i[2]
            else:
                S = i[2]+S
if left:
    print(S)
else:
    print(S[::-1])


Fixed submission:
# coding: utf-8

S = input()
Q = int(input())

query = []

for i in range(Q):
    query.append(input().split())


bool = True
pre =''
suf =''

for i in query:
    if len(i) == 1:
        bool = not(bool)

    else:
        if i[1]=="1":
            if bool:
                pre = i[2]+pre
            else:
                suf += i[2]
        else:
            if bool:
                suf += i[2]
            else:
                pre = i[2]+pre

S = pre+ S +suf
print(S) if bool else print(S[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

S = input()
Q = int(input())
# print("S:{}".format(S))
# print("Q:{}".format(Q))
query = []

for i in range(Q):
    query.append(input().split())
# for i in query:
#     print(i)

for i in query:
    if len(i) == 1:
        S = S[::-1]
    else:
        if i[1]=="1":
            S = i[2]+S
        else:
            S += i[2]
print(S)


Fixed submission:
# coding: utf-8

S = input()
Q = int(input())

query = []

for i in range(Q):
    query.append(input().split())


bool = True
pre =''
suf =''

for i in query:
    if len(i) == 1:
        bool = not(bool)

    else:
        if i[1]=="1":
            if bool:
                pre = i[2]+pre
            else:
                suf += i[2]
        else:
            if bool:
                suf += i[2]
            else:
                pre = i[2]+pre

S = pre+ S +suf
print(S) if bool else print(S[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

S = input()
Q = int(input())
# print("S:{}".format(S))
# print("Q:{}".format(Q))
query = []

for i in range(Q):
    query.append(input().split())
# for i in query:
#     print(i)
new_s=""
leng= len(S)
for i in query:
    if len(i) == 1:
        S = S[::-1]
    else:
        if i[1]=="1":
            S = i[2]+S
        else:
            S = S+i[2]
print(S)


Fixed submission:
# coding: utf-8

S = input()
Q = int(input())

query = []

for i in range(Q):
    query.append(input().split())


bool = True
pre =''
suf =''

for i in query:
    if len(i) == 1:
        bool = not(bool)

    else:
        if i[1]=="1":
            if bool:
                pre = i[2]+pre
            else:
                suf += i[2]
        else:
            if bool:
                suf += i[2]
            else:
                pre = i[2]+pre

S = pre+ S +suf
print(S) if bool else print(S[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

S = input()
Q = int(input())
# print("S:{}".format(S))
# print("Q:{}".format(Q))
query = []

for i in range(Q):
    query.append(input().split())
# for i in query:
#     print(i)
for i in query:
    if len(i) == 1:
        S = ''.join(list(reversed(S)))
    else:
        if i[1]=="1":
            S = i[2]+S
        else:
            S = S+i[2]
print(S)


Fixed submission:
# coding: utf-8

S = input()
Q = int(input())

query = []

for i in range(Q):
    query.append(input().split())


bool = True
pre =''
suf =''

for i in query:
    if len(i) == 1:
        bool = not(bool)

    else:
        if i[1]=="1":
            if bool:
                pre = i[2]+pre
            else:
                suf += i[2]
        else:
            if bool:
                suf += i[2]
            else:
                pre = i[2]+pre

S = pre+ S +suf
print(S) if bool else print(S[::-1])

Buggy python submission (verdict: Runtime Error):
# coding: utf-8

a, b = map(int, input().split())
# print(a,b)
# x=-1
# y=-1

xr=[]
yr=[]
for i in range(101):
    if i*0.08//1==a:
        # print("x:{}".format(i))
        x=i
        xr.append(x)
for i in range(101):
    if i *0.1//1==b:
        # print("y:{}".format(i))
        y=i
        yr.append(y)
flag=False

for i in xr:
    for j in yr:
        if i==j:
            print(i)
            flag=True
            break
    if flag:
        break
if not flag:
    print(-1)


Fixed submission:
# coding: utf-8

S = input()
Q = int(input())

query = []

for i in range(Q):
    query.append(input().split())


bool = True
pre =''
suf =''

for i in query:
    if len(i) == 1:
        bool = not(bool)

    else:
        if i[1]=="1":
            if bool:
                pre = i[2]+pre
            else:
                suf += i[2]
        else:
            if bool:
                suf += i[2]
            else:
                pre = i[2]+pre

S = pre+ S +suf
print(S) if bool else print(S[::-1])