from collections import deque



s = eval(input())

q = int(eval(input()))



reverse = False

count = 0

mae = deque()

ushiro = deque()

for i in range(q):

    qu = eval(input())

    if qu[0] == "1":

        count += 1

        if reverse:

            reverse = False

        else:

            reverse = True

    else:

        _, f, c = qu.split()

        if reverse:

            if f == "1":

                ushiro.append(c)

            else:

                mae.appendleft(c)

        else:

            if f == "1":

                mae.appendleft(c)

            else:

                ushiro.append(c)



s = "".join(mae) + s + "".join(ushiro)



if count % 2:

    print((s[::-1]))

else:

    print(s)

s = eval(input())

q = int(eval(input()))



reverse = False

count = 0

mae = []

ushiro = []

for i in range(q):

    qu = eval(input())

    if qu[0] == "1":

        count += 1

        if reverse:

            reverse = False

        else:

            reverse = True

    else:

        _, f, c = qu.split()

        if reverse:

            if f == "1":

                ushiro.append(c)

            else:

                mae.append(c)

        else:

            if f == "1":

                mae.append(c)

            else:

                ushiro.append(c)



s = "".join(mae[::-1]) + s + "".join(ushiro)



if count % 2:

    print((s[::-1]))

else:

    print(s)

from collections import deque

s = eval(input())
q = int(eval(input()))
reverse = False
count = 0
mae = deque()
ushiro = deque()
for i in range(q):
    qu = eval(input())
    if qu[0] == "1":
        count += 1
        if reverse:
            reverse = False
        else:
            reverse = True
    else:
        _, f, c = qu.split()
        if reverse:
            if f == "1":
                ushiro.append(c)
            else:
                mae.appendleft(c)
        else:
            if f == "1":
                mae.appendleft(c)
            else:
                ushiro.append(c)
s = "".join(mae) + s + "".join(ushiro)
if count % 2:
    print((s[::-1]))
else:
    print(s)

s = eval(input())
q = int(eval(input()))
reverse = False
count = 0
mae = []
ushiro = []
for i in range(q):
    qu = eval(input())
    if qu[0] == "1":
        count += 1
        if reverse:
            reverse = False
        else:
            reverse = True
    else:
        _, f, c = qu.split()
        if reverse:
            if f == "1":
                ushiro.append(c)
            else:
                mae.append(c)
        else:
            if f == "1":
                mae.append(c)
            else:
                ushiro.append(c)
s = "".join(mae[::-1]) + s + "".join(ushiro)
if count % 2:
    print((s[::-1]))
else:
    print(s)

-from collections import deque - -mae = deque() -ushiro = deque() +mae = [] +ushiro = [] -                mae.appendleft(c) +                mae.append(c) -                mae.appendleft(c) +                mae.append(c) -s = "".join(mae) + s + "".join(ushiro) +s = "".join(mae[::-1]) + s + "".join(ushiro)