Buggy python submission (verdict: Runtime Error):
#D
s_list=list(input())
q=int(input())
r=0
sl_list=[]
for i in range(q):
    ope=input().split()
    if ope[0]=='1':
        r+=1
    else:
        if (int(ope[1])+r)%2 == 1:
            sl_list.append(ope[2])
        else:
            s_list.append(ope[2])
s_list=sl_list.reverse() + s_list
if r%2 !=0:
    s_list.reverse()
print(''.join(s_list))

Fixed submission:
#D
s_list=list(input())
q=int(input())
r=0
sl_list=[]
for i in range(q):
    ope=input().split()
    if ope[0]=='1':
        r+=1
    else:
        if (int(ope[1])+r)%2 == 1:
            sl_list.append(ope[2])
        else:
            s_list.append(ope[2])
sl_list.reverse()
s_list=sl_list + s_list
if r%2 !=0:
    s_list.reverse()
print(''.join(s_list))

Buggy python submission (verdict: Time Limit Exceeded):
#D
s_list=list(input())
q=int(input())
r=0
for i in range(q):
    ope=input().split()
    if ope[0]=='1':
        r+=1
    else:
        if (int(ope[1])+r)%2 == 1:
            s_list.insert(0,ope[2])
        else:
            s_list.append(ope[2])
if r%2 !=0:
    s_list.reverse()
print(''.join(s_list))

Fixed submission:
#D
s_list=list(input())
q=int(input())
r=0
sl_list=[]
for i in range(q):
    ope=input().split()
    if ope[0]=='1':
        r+=1
    else:
        if (int(ope[1])+r)%2 == 1:
            sl_list.append(ope[2])
        else:
            s_list.append(ope[2])
sl_list.reverse()
s_list=sl_list + s_list
if r%2 !=0:
    s_list.reverse()
print(''.join(s_list))

Buggy python submission (verdict: Time Limit Exceeded):
#D
s_list=list(input())
q=int(input())

for i in range(q):
    ope=input().split()
    if ope[0]=='1':
        s_list.reverse()
    else:
        if ope[1]=='1':
            s_list=list(ope[2])+s_list
        else:
            s_list=s_list+list(ope[2])
print(''.join(s_list))

Fixed submission:
#D
s_list=list(input())
q=int(input())
r=0
sl_list=[]
for i in range(q):
    ope=input().split()
    if ope[0]=='1':
        r+=1
    else:
        if (int(ope[1])+r)%2 == 1:
            sl_list.append(ope[2])
        else:
            s_list.append(ope[2])
sl_list.reverse()
s_list=sl_list + s_list
if r%2 !=0:
    s_list.reverse()
print(''.join(s_list))

Buggy python submission (verdict: Time Limit Exceeded):
#D
s_list=list(input())
q=int(input())

for i in range(q):
    ope=input().split()
    if ope[0]=='1':
        s_list.reverse()
    else:
        if ope[1]=='1':
            s_list.insert(0,ope[2])
        else:
            s_list.append(ope[2])
print(''.join(s_list))

Fixed submission:
#D
s_list=list(input())
q=int(input())
r=0
sl_list=[]
for i in range(q):
    ope=input().split()
    if ope[0]=='1':
        r+=1
    else:
        if (int(ope[1])+r)%2 == 1:
            sl_list.append(ope[2])
        else:
            s_list.append(ope[2])
sl_list.reverse()
s_list=sl_list + s_list
if r%2 !=0:
    s_list.reverse()
print(''.join(s_list))

Buggy python submission (verdict: Time Limit Exceeded):
#D
s_list=list(input())
q=int(input())

for i in range(q):
    ope=input().split()
    if ope[0]=='1':
        s_list.reverse()
    else:
        if ope[1]=='1':
            s_list.insert(0,ope[2])
        else:
            s_list.append(ope[2])
print(''.join(s_list))

Fixed submission:
#D
s_list=list(input())
q=int(input())
r=0
sl_list=[]
for i in range(q):
    ope=input().split()
    if ope[0]=='1':
        r+=1
    else:
        if (int(ope[1])+r)%2 == 1:
            sl_list.append(ope[2])
        else:
            s_list.append(ope[2])
sl_list.reverse()
s_list=sl_list + s_list
if r%2 !=0:
    s_list.reverse()
print(''.join(s_list))