Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = int(input())

# for t in try_list:
#     if t[0] == '1':
#         s = ''.join(list(reversed(s)))
#     if t[0] == '2':
#         if t[1] == '1':
#             s = t[2] + s
#         else:
#             s = s + t[2]

# 反転の処理に時間がかかる

head = 0
for i in range(n):
    t = input().split()
    # 先頭
    if t[0] == '1':
        # 末尾
        head += 1
    else:
        if (head + int(t[1])) % 2 == 1:
            s = t[2] + s
        else:
            s = s + t[2]
if head % 2 == 0:
    print(s)
else:
    print(''.join(list(reversed(s))))

Fixed submission:
s = input()
n = int(input())

t = ''
for i in range(n):
    q = input().split()
    if len(q) == 1:
        t, s = s, t
    elif len(q) == 3:
        if q[1] == '1':
            t += q[2]
        elif q[1] == '2':
            s += q[2]

t = t[::-1]
print(t + s)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = int(input())

try_list = []
for i in range(n):
    t = input().split()
    try_list.append(t)

head = 0
for t in try_list:
    # 先頭
    if t[0] == '1':
        # 末尾
        head += 1
    else:
        if (head + int(t[1])) % 2 == 1:
            s = t[2] + s
        else:
            s = s + t[2]
if head % 2 == 0:
    print(s)
else:
    print(''.join(list(reversed(s))))

Fixed submission:
s = input()
n = int(input())

t = ''
for i in range(n):
    q = input().split()
    if len(q) == 1:
        t, s = s, t
    elif len(q) == 3:
        if q[1] == '1':
            t += q[2]
        elif q[1] == '2':
            s += q[2]

t = t[::-1]
print(t + s)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = int(input())

try_list = []
for i in range(n):
    t = input().split()
    try_list.append(t)

head = 0
for t in try_list:
    # 先頭
    if t[0] == '1':
        # 末尾
        head += 1
    else:
        # 先頭
        if head % 2 == 0:
            if t[1] == '1':
                s = t[2] + s
            else:
                s = s + t[2]
        else:
            if t[1] == '1':
                s = s + t[2]
            else:
                s = t[2] + s
if head % 2 == 0:
    print(s)
else:
    print(''.join(list(reversed(s))))

Fixed submission:
s = input()
n = int(input())

t = ''
for i in range(n):
    q = input().split()
    if len(q) == 1:
        t, s = s, t
    elif len(q) == 3:
        if q[1] == '1':
            t += q[2]
        elif q[1] == '2':
            s += q[2]

t = t[::-1]
print(t + s)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = int(input())

try_list = []
for i in range(n):
    t = input().split()
    try_list.append(t)

for t in try_list:
    if t[0] == '1':
        s = ''.join(list(reversed(s)))
    if t[0] == '2':
        if t[1] == '1':
            s = t[2] + s
        else:
            s = s + t[2]

print(s)

Fixed submission:
s = input()
n = int(input())

t = ''
for i in range(n):
    q = input().split()
    if len(q) == 1:
        t, s = s, t
    elif len(q) == 3:
        if q[1] == '1':
            t += q[2]
        elif q[1] == '2':
            s += q[2]

t = t[::-1]
print(t + s)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = int(input())

for i in range(n):
    t = input().split()
    if t[0] == '1':
        s = ''.join(list(reversed(s)))
    if t[0] == '2':
        if t[1] == '1':
            s = t[2] + s
        else:
            s = s + t[2]

print(s)

Fixed submission:
s = input()
n = int(input())

t = ''
for i in range(n):
    q = input().split()
    if len(q) == 1:
        t, s = s, t
    elif len(q) == 3:
        if q[1] == '1':
            t += q[2]
        elif q[1] == '2':
            s += q[2]

t = t[::-1]
print(t + s)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = int(input())

for i in range(n):
    t = input().split()
    if t[0] == '1':
        s = ''.join(list(reversed(s)))
    if t[0] == '2':
        if t[1] == '1':
            s = t[2] + s
        else:
            s = s + t[2]

print(s)

Fixed submission:
s = input()
n = int(input())

t = ''
for i in range(n):
    q = input().split()
    if len(q) == 1:
        t, s = s, t
    elif len(q) == 3:
        if q[1] == '1':
            t += q[2]
        elif q[1] == '2':
            s += q[2]

t = t[::-1]
print(t + s)