s=list(input())
top=bool()
t=[]
u=[]
n=int(input())
for i in range(n):
  q=list(map(str,input().split()))
  if q[0]=='1':
    top=not top
  else:
    if (q[1]=="1") ^ top:
      t.append(q[2])
    else:
      u.append(q[2])
s=list(reversed(t))+s+u
if top:
  print(*list(reversed(s)),sep='')
else:
  print(*s,sep='')
14f8605a7e5b0f58a35f806d34c84b2bfb235923
<mask token>

<mask token>
for i in range(n):
    q = list(map(str, input().split()))
    if q[0] == '1':
        top = not top
    elif (q[1] == '1') ^ top:
        t.append(q[2])
    else:
        u.append(q[2])
<mask token>
if top:
    print(*list(reversed(s)), sep='')
else:
    print(*s, sep='')

s = list(input())
top = bool()
t = []
u = []
n = int(input())
for i in range(n):
    q = list(map(str, input().split()))
    if q[0] == '1':
        top = not top
    elif (q[1] == '1') ^ top:
        t.append(q[2])
    else:
        u.append(q[2])
s = list(reversed(t)) + s + u
if top:
    print(*list(reversed(s)), sep='')
else:
    print(*s, sep='')

s=list(input())
top=bool()
t=[]
u=[]
n=int(input())
for i in range(n):
  q=list(map(str,input().split()))
  if q[0]=='1':
    top=not top
  else:
    if (q[1]=="1") ^ top:
      t.append(q[2])
    else:
      u.append(q[2])
s=list(reversed(t))+s+u
if top:
  print(*list(reversed(s)),sep='')
else:
  print(*s,sep='')