from collections import deque

s = deque(eval(input()))

#s = input()

n = int(eval(input()))

f = 1

for i in range(n):

  l = list(map(str, input().split()))

  if l[0] == "2":

    tmp = int(l[1])*f

    if tmp == 1 or tmp == -2:

      s.appendleft(l[2])

    else:

      s.append(l[2])

  else:

    f *= -1



if f == -1:

  s.reverse()

print(("".join(s)))

from collections import deque

s = deque(eval(input()))

n = int(eval(input()))

f = 0

for i in range(n):

  l = list(map(str, input().split()))

  if l[0] == "2":

    if (l[1] == "1" and f == 0) or (l[1] == "2" and f == 1):

      s.appendleft(l[2])

    else:

      s.append(l[2])

  else:

    if f == 0:

      f = 1

    else:

      f = 0

if f == 1:

  s.reverse()

print(("".join(s)))

from collections import deque

s = deque(eval(input()))
# s = input()
n = int(eval(input()))
f = 1
for i in range(n):
    l = list(map(str, input().split()))
    if l[0] == "2":
        tmp = int(l[1]) * f
        if tmp == 1 or tmp == -2:
            s.appendleft(l[2])
        else:
            s.append(l[2])
    else:
        f *= -1
if f == -1:
    s.reverse()
print(("".join(s)))

from collections import deque

s = deque(eval(input()))
n = int(eval(input()))
f = 0
for i in range(n):
    l = list(map(str, input().split()))
    if l[0] == "2":
        if (l[1] == "1" and f == 0) or (l[1] == "2" and f == 1):
            s.appendleft(l[2])
        else:
            s.append(l[2])
    else:
        if f == 0:
            f = 1
        else:
            f = 0
if f == 1:
    s.reverse()
print(("".join(s)))

-# s = input() -f = 1 +f = 0 -        tmp = int(l[1]) * f -        if tmp == 1 or tmp == -2: +        if (l[1] == "1" and f == 0) or (l[1] == "2" and f == 1): -        f *= -1 -if f == -1: +        if f == 0: +            f = 1 +        else: +            f = 0 +if f == 1: