import sys

#input=sys.stdin.readline

from collections import deque



r=False

d=deque(list(eval(input())))

for i in range(int(eval(input()))):

  Q=input().split()

  if Q[0]=='1':

    r=not r

  else:

    if (Q[1]=='1' and not r) or (Q[1]=='2' and r):

      d.appendleft(Q[2])

    else:

      d.append(Q[2])



if r:

  d.reverse()



print(("".join(list(d))))

import sys

input=lambda:sys.stdin.readline().rstrip()

from collections import deque



r=False

d=deque(list(eval(input())))

for i in range(int(eval(input()))):

  Q=input().split()

  if Q[0]=='1':

    r=not r

  else:

    if (Q[1]=='1' and not r) or (Q[1]=='2' and r):

      d.appendleft(Q[2])

    else:

      d.append(Q[2])



if r:

  d.reverse()



print(("".join(list(d))))

import sys

# input=sys.stdin.readline
from collections import deque

r = False
d = deque(list(eval(input())))
for i in range(int(eval(input()))):
    Q = input().split()
    if Q[0] == "1":
        r = not r
    else:
        if (Q[1] == "1" and not r) or (Q[1] == "2" and r):
            d.appendleft(Q[2])
        else:
            d.append(Q[2])
if r:
    d.reverse()
print(("".join(list(d))))

import sys

input = lambda: sys.stdin.readline().rstrip()
from collections import deque

r = False
d = deque(list(eval(input())))
for i in range(int(eval(input()))):
    Q = input().split()
    if Q[0] == "1":
        r = not r
    else:
        if (Q[1] == "1" and not r) or (Q[1] == "2" and r):
            d.appendleft(Q[2])
        else:
            d.append(Q[2])
if r:
    d.reverse()
print(("".join(list(d))))

-# input=sys.stdin.readline +input = lambda: sys.stdin.readline().rstrip()