Buggy python submission (verdict: Runtime Error):
from collections import deque
S = list(input())
Q = int(input())
perm = 0
d = deque(S)

for i in range(0, Q):
    l = input().split()
    if len(l) == 1:
        perm += 1
    else:
        if (int(l[1])+perm) % 2 == 0:
            d.append(l[2])
        else:
            d.insert(0, l[2])
 
S0 = list(d)
if perm % 2 != 0:
    S0.reverse()
ans = ""
for i in range(0, len(S0)):
    ans = ans + S0[i]
print(ans)

Fixed submission:
from collections import deque
S = list(input())
Q = int(input())
perm = 0
d = deque(S)

for i in range(0, Q):
    l = input().split()
    if len(l) == 1:
        perm += 1
    else:
        if (int(l[1])+perm) % 2 == 0:
            d.append(l[2])
        else:
            d.appendleft(l[2])
 
S0 = list(d)
if perm % 2 != 0:
    S0.reverse()
ans = ""
for i in range(0, len(S0)):
    ans = ans + S0[i]
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 22 10:29:00 2020

@author: azikausy
"""

from collections import deque
S = list(input())
Q = int(input())
#Query = {}
#TFC = []
perm = 0
d = deque(S)
for i in range(0, Q):
    l = input().split()
    if len(l) == 1:
        #Query[i] = [l[0], 0, 0]
        #S.reverse()
        perm += 1
    else:
        #Query[i] = l
        if (int(l[1])+perm) % 2 == 0:
            d.append(l[2])
        else:
            d.insert(0, l[2])

#print(d)
S0 = list(d)
#print(S0)
if perm % 2 != 0:
    S0.reverse()
ans = ""
for i in range(0, len(S0)):
    ans = ans + S0[i]
print(ans)

Fixed submission:
from collections import deque
S = list(input())
Q = int(input())
perm = 0
d = deque(S)

for i in range(0, Q):
    l = input().split()
    if len(l) == 1:
        perm += 1
    else:
        if (int(l[1])+perm) % 2 == 0:
            d.append(l[2])
        else:
            d.appendleft(l[2])
 
S0 = list(d)
if perm % 2 != 0:
    S0.reverse()
ans = ""
for i in range(0, len(S0)):
    ans = ans + S0[i]
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 22 10:29:00 2020

@author: azikausy
"""

from collections import deque
S = list(input())
Q = int(input())
#Query = {}
#TFC = []
perm = 0
d =deque(S)
for i in range(0, Q):
    l = input().split()
    if len(l) == 1:
        #Query[i] = [l[0], 0, 0]
        #S.reverse()
        perm += 1
    else:
        #Query[i] = l
        if (int(l[1])+perm) % 2 == 0:
            d.append(l[2])
        else:
            d.insert(0, l[2])

S0 = list(d)
if perm % 2 != 0:
    S0.reverse()
ans = ""
for i in range(0, len(S0)):
    ans = ans + S0[i]
print(ans)


Fixed submission:
from collections import deque
S = list(input())
Q = int(input())
perm = 0
d = deque(S)

for i in range(0, Q):
    l = input().split()
    if len(l) == 1:
        perm += 1
    else:
        if (int(l[1])+perm) % 2 == 0:
            d.append(l[2])
        else:
            d.appendleft(l[2])
 
S0 = list(d)
if perm % 2 != 0:
    S0.reverse()
ans = ""
for i in range(0, len(S0)):
    ans = ans + S0[i]
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 22 09:27:00 2020

@author: azikausy
"""
from collections import deque

S = list(input())
Q = int(input())
#Query = {}
#TFC = []
perm = 0
d = deque(S)
#l = []
for i in range(0, Q):
    l = input().split()
    if len(l) == 1:
        #Query[i] = [l[0], 0, 0]
        #S.reverse()
        perm += 1
    else:
        #l[2] = l[2] + perm
        #Query[i] = l
        if (int(l[1])+perm) % 2 == 0:
            d.append(l[2])
        else:
            d.insert(0, l[2])

S0 = list(d)
if perm % 2 != 0:
    S0.reverse()
ans = ""
for i in range(0, len(S0)):
    ans = ans + S0[i]
print(ans)

Fixed submission:
from collections import deque
S = list(input())
Q = int(input())
perm = 0
d = deque(S)

for i in range(0, Q):
    l = input().split()
    if len(l) == 1:
        perm += 1
    else:
        if (int(l[1])+perm) % 2 == 0:
            d.append(l[2])
        else:
            d.appendleft(l[2])
 
S0 = list(d)
if perm % 2 != 0:
    S0.reverse()
ans = ""
for i in range(0, len(S0)):
    ans = ans + S0[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 22 09:27:00 2020

@author: azikausy
"""


S = list(input())
Q = int(input())
Query = {}
#TFC = []
perm = 0
for i in range(0, Q):
    l = input().split()
    if len(l) == 1:
        #Query[i] = [l[0], 0, 0]
        #S.reverse()
        perm += 1
    else:
        #Query[i] = l
        if (int(l[1])+perm) % 2 == 0:
            S.append(l[2])
        else:
            S.insert(0, l[2])
if perm % 2 != 0:
    S.reverse()
ans = ""
for i in range(0, len(S)):
    ans = ans + S[i]
print(ans)

Fixed submission:
from collections import deque
S = list(input())
Q = int(input())
perm = 0
d = deque(S)

for i in range(0, Q):
    l = input().split()
    if len(l) == 1:
        perm += 1
    else:
        if (int(l[1])+perm) % 2 == 0:
            d.append(l[2])
        else:
            d.appendleft(l[2])
 
S0 = list(d)
if perm % 2 != 0:
    S0.reverse()
ans = ""
for i in range(0, len(S0)):
    ans = ans + S0[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 22 09:27:00 2020

@author: azikausy
"""


S = list(input())
Q = int(input())
Query = {}
#TFC = []
for i in range(0, Q):
    l = input().split()
    if len(l) == 1:
        #Query[i] = [l[0], 0, 0]
        S.reverse() 
    else:
        #Query[i] = l
        if l[1] == "2":
            S.append(l[2])
        else:
            S.insert(0, l[2])

ans = ""
for i in range(0, len(S)):
    ans = ans + S[i]
print(ans)

Fixed submission:
from collections import deque
S = list(input())
Q = int(input())
perm = 0
d = deque(S)

for i in range(0, Q):
    l = input().split()
    if len(l) == 1:
        perm += 1
    else:
        if (int(l[1])+perm) % 2 == 0:
            d.append(l[2])
        else:
            d.appendleft(l[2])
 
S0 = list(d)
if perm % 2 != 0:
    S0.reverse()
ans = ""
for i in range(0, len(S0)):
    ans = ans + S0[i]
print(ans)