*s, = eval(input())

_q = int(eval(input()))

rev = 0

l, r = [], []

for _ in range(_q):

    *q, = list(map(str, input().split()))



    if q[0] == "1":

        rev += 1

        continue



    t = q[0]

    f = q[1]

    c = q[2]



    if rev%2 == 0:

        if f == "1":

            l.append(c)

        else:

            r.append(c)

    else:

        if f == "1":

            r.append(c)

        else:

            l.append(c)



*l, = reversed(l)



s = l + s + r



if rev%2 == 1:

    *s, = reversed(s)



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

import collections

s = eval(input())

_q = int(eval(input()))

q = collections.deque(s)



rev = False

for _ in range(_q):

    *query, = list(map(str, input().split()))



    if query[0] == "1":

        rev = not rev

        continue



    f, c = query[1], query[2]



    if rev ^ (f == "1"):

        q.appendleft(c)

    else:

        q.append(c)



if rev:

    q.reverse()



print(("".join(q)))

(*s,) = eval(input())
_q = int(eval(input()))
rev = 0
l, r = [], []
for _ in range(_q):
    (*q,) = list(map(str, input().split()))
    if q[0] == "1":
        rev += 1
        continue
    t = q[0]
    f = q[1]
    c = q[2]
    if rev % 2 == 0:
        if f == "1":
            l.append(c)
        else:
            r.append(c)
    else:
        if f == "1":
            r.append(c)
        else:
            l.append(c)
(*l,) = reversed(l)
s = l + s + r
if rev % 2 == 1:
    (*s,) = reversed(s)
print(("".join(s)))

import collections

s = eval(input())
_q = int(eval(input()))
q = collections.deque(s)
rev = False
for _ in range(_q):
    (*query,) = list(map(str, input().split()))
    if query[0] == "1":
        rev = not rev
        continue
    f, c = query[1], query[2]
    if rev ^ (f == "1"):
        q.appendleft(c)
    else:
        q.append(c)
if rev:
    q.reverse()
print(("".join(q)))

-(*s,) = eval(input()) +import collections + +s = eval(input()) -rev = 0 -l, r = [], [] +q = collections.deque(s) +rev = False -    (*q,) = list(map(str, input().split())) -    if q[0] == "1": -        rev += 1 +    (*query,) = list(map(str, input().split())) +    if query[0] == "1": +        rev = not rev -    t = q[0] -    f = q[1] -    c = q[2] -    if rev % 2 == 0: -        if f == "1": -            l.append(c) -        else: -            r.append(c) +    f, c = query[1], query[2] +    if rev ^ (f == "1"): +        q.appendleft(c) -        if f == "1": -            r.append(c) -        else: -            l.append(c) -(*l,) = reversed(l) -s = l + s + r -if rev % 2 == 1: -    (*s,) = reversed(s) -print(("".join(s))) +        q.append(c) +if rev: +    q.reverse() +print(("".join(q)))