Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = int(input())
cnt = 0
for i in range(n):
    a = input()
    if a == "1":
        cnt +=1
    else:
        if a[2] == "1" and cnt%2 ==0:
            s = a[4] + s
        elif a[2] == "1" and cnt%2 ==1:
            s = s + a[4]
        elif a[2] == "2" and cnt%2 ==0:
            s = s + a[4]
        elif a[2] == "2" and cnt%2 ==1:
            s = a[4] + s

if cnt%2 == 1:
    print(s[::-1])
else:
    print(s)

Fixed submission:
from collections import deque
s = input()
s = deque(s)
n = int(input())
cnt = False
for i in range(n):
  L = input()
  if len(L) == 1:
    cnt  ^=1 
  else:
    a,b,c = L.split()
    if cnt:
      if b == "1":
        s.append(c)
      else:
        s.appendleft(c)
    else:
      if b == "1":
        s.appendleft(c)
      else:
        s.append(c)
if cnt:
    s = reversed(s)
    print("".join(s))
else:
    print("".join(s))

Buggy python submission (verdict: Runtime Error):
rom collections import deque
s = input()
n = int(input())
s = deque(s)
cnt = 0
def ap(s,a,b):
    if flag ==True:
        if a == "1":
            s.appendleft(b)
        elif a == "2":
            s.append(b)
    if flag == False:
        if a == "1": 
            s.append(b)
        elif a == "2":
            s.appendleft(b)
flag = True
for i in range(n):
    L = list(input())
    if L[0] == "1":
        flag = False
        cnt +=1
    elif L[0] == "2":
        ap(s,L[2],L[4])
        flag = True
#print(flag,cnt,s)
if cnt %2 == 1:
    s.reverse()
print("".join(s))

Fixed submission:
from collections import deque
s = input()
s = deque(s)
n = int(input())
cnt = False
for i in range(n):
  L = input()
  if len(L) == 1:
    cnt  ^=1 
  else:
    a,b,c = L.split()
    if cnt:
      if b == "1":
        s.append(c)
      else:
        s.appendleft(c)
    else:
      if b == "1":
        s.appendleft(c)
      else:
        s.append(c)
if cnt:
    s = reversed(s)
    print("".join(s))
else:
    print("".join(s))

Buggy python submission (verdict: Runtime Error):
s = list(input())
n = int(input())
import numpy as np

s = np.array(s)

L = []
for i in range(n):
    L = (list(map(str,input())))
    #print(L)
    if len(L) >1:
        if int(L[2]) == 1:
            #print(s)
            s = np.append(L[4],s)
        elif int(L[2]) == 2:
            s = np.append(s,L[4])
    
    elif len(L) ==1:
        s = np.rot90(s, 2)
        
print("".join(s))

Fixed submission:
from collections import deque
s = input()
s = deque(s)
n = int(input())
cnt = False
for i in range(n):
  L = input()
  if len(L) == 1:
    cnt  ^=1 
  else:
    a,b,c = L.split()
    if cnt:
      if b == "1":
        s.append(c)
      else:
        s.appendleft(c)
    else:
      if b == "1":
        s.appendleft(c)
      else:
        s.append(c)
if cnt:
    s = reversed(s)
    print("".join(s))
else:
    print("".join(s))

Buggy python submission (verdict: Runtime Error):
s = list(input())
n = int(input())
import numpy as np

s = np.array(s)

L = []
for i in range(n):
    L = (list(map(str,input())))
    #print(L)
    if len(L) >1:
        if int(L[2]) == 1:
            #print(s)
            s = np.append(L[4],s)
        elif int(L[2]) == 2:
            s = np.append(s,L[4])
    
    elif len(L) ==1:
        s = np.rot90(s, 2)
        
print("".join(s))

Fixed submission:
from collections import deque
s = input()
s = deque(s)
n = int(input())
cnt = False
for i in range(n):
  L = input()
  if len(L) == 1:
    cnt  ^=1 
  else:
    a,b,c = L.split()
    if cnt:
      if b == "1":
        s.append(c)
      else:
        s.appendleft(c)
    else:
      if b == "1":
        s.appendleft(c)
      else:
        s.append(c)
if cnt:
    s = reversed(s)
    print("".join(s))
else:
    print("".join(s))

Buggy python submission (verdict: Runtime Error):
s = list(input())
n = int(input())
import numpy as np
import collections
s = np.array(s)
s = collections.deque(s)
L = []
for i in range(n):
    L = (list(map(str,input())))
    #print(L)
    if len(L) >1:
        if int(L[2]) == 1:
            #print(s)
            s = np.append(L[4],s)
        elif int(L[2]) == 2:
            s = np.append(s,L[4])
    
    elif len(L) ==1:
        s = np.flipud(s)
        
print("".join(s))

Fixed submission:
from collections import deque
s = input()
s = deque(s)
n = int(input())
cnt = False
for i in range(n):
  L = input()
  if len(L) == 1:
    cnt  ^=1 
  else:
    a,b,c = L.split()
    if cnt:
      if b == "1":
        s.append(c)
      else:
        s.appendleft(c)
    else:
      if b == "1":
        s.appendleft(c)
      else:
        s.append(c)
if cnt:
    s = reversed(s)
    print("".join(s))
else:
    print("".join(s))

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = int(input())
import numpy as np
import collections
s = np.array(s)
s = collections.deque(s)
L = []
for i in range(n):
    L = (list(map(str,input())))
    #print(L)
    if len(L) >1:
        if int(L[2]) == 1:
            #print(s)
            s = np.append(L[4],s)
        elif int(L[2]) == 2:
            s = np.append(s,L[4])
    
    elif len(L) ==1:
        s = np.flipud(s)
        
print("".join(s))

Fixed submission:
from collections import deque
s = input()
s = deque(s)
n = int(input())
cnt = False
for i in range(n):
  L = input()
  if len(L) == 1:
    cnt  ^=1 
  else:
    a,b,c = L.split()
    if cnt:
      if b == "1":
        s.append(c)
      else:
        s.appendleft(c)
    else:
      if b == "1":
        s.appendleft(c)
      else:
        s.append(c)
if cnt:
    s = reversed(s)
    print("".join(s))
else:
    print("".join(s))

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

import collections
s = collections.deque(s)
L = []
for i in range(n):
    L = (list(map(str,input())))
    #print(L)
    if len(L) >1:
        if int(L[2]) == 1:
            #print(s)
            s.appendleft(L[4])
        elif int(L[2]) == 2:
            s.append(L[4])
    
    elif len(L) ==1:
        s.reverse()
print("".join(s))

Fixed submission:
from collections import deque
s = input()
s = deque(s)
n = int(input())
cnt = False
for i in range(n):
  L = input()
  if len(L) == 1:
    cnt  ^=1 
  else:
    a,b,c = L.split()
    if cnt:
      if b == "1":
        s.append(c)
      else:
        s.appendleft(c)
    else:
      if b == "1":
        s.appendleft(c)
      else:
        s.append(c)
if cnt:
    s = reversed(s)
    print("".join(s))
else:
    print("".join(s))

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

import collections
s = collections.deque(s)
L = []
for i in range(n):
    L = (list(map(str,input())))
    #print(L)
    if len(L) >1:
        if int(L[2]) == 1:
            #print(s)
            s.appendleft(L[4])
        elif int(L[2]) == 2:
            s.append(L[4])
    
    elif len(L) ==1:
        s.reverse()
print("".join(s))

Fixed submission:
from collections import deque
s = input()
s = deque(s)
n = int(input())
cnt = False
for i in range(n):
  L = input()
  if len(L) == 1:
    cnt  ^=1 
  else:
    a,b,c = L.split()
    if cnt:
      if b == "1":
        s.append(c)
      else:
        s.appendleft(c)
    else:
      if b == "1":
        s.appendleft(c)
      else:
        s.append(c)
if cnt:
    s = reversed(s)
    print("".join(s))
else:
    print("".join(s))