from collections import deque

S = input()

Q = int(input())

query = [list(input().split()) for _ in range(Q)]

reversecount = 0

d = deque(S)

for x in query:

    if int(x[0]) == 1:

        reversecount += 1

    else:

        if (int(x[1]) == 1 and (reversecount % 2 == 0)) or (int(x[1]) == 2 and (reversecount % 2 == 1)):

            d.appendleft(x[2])

        else:

            d.append(x[2])

if reversecount % 2 == 1:

    d.reverse()

print(*d, sep='')

def main2(s,x,q):

    res = s

    rev = 1 #-1なら反転中

    lstA = []

    lstB = []

    for op in q:

        if int(op[0]) == 1:

            rev = rev * -1

        elif int(op[1])*rev == 1 or int(op[1])*rev == -2:

            lstA.append(op[2])

        elif int(op[1])*rev == -1 or int(op[1])*rev == 2:

            lstB.append(op[2])

    if rev == 1:

        res = "".join(lstA[::-1])+res+"".join(lstB)

    else :

        res = "".join(lstB[::-1])+res[::-1]+"".join(lstA)

    return res

 

s = eval(input())

x = int(eval(input()))

q = [input().split() for _ in range(x)]

print((main2(s,x,q)))
from collections import deque

S = input()
Q = int(input())
query = [list(input().split()) for _ in range(Q)]
reversecount = 0
d = deque(S)
for x in query:
    if int(x[0]) == 1:
        reversecount += 1
    else:
        if (int(x[1]) == 1 and (reversecount % 2 == 0)) or (
            int(x[1]) == 2 and (reversecount % 2 == 1)
        ):
            d.appendleft(x[2])
        else:
            d.append(x[2])
if reversecount % 2 == 1:
    d.reverse()
print(*d, sep="")

def main2(s, x, q):
    res = s
    rev = 1  # -1なら反転中
    lstA = []
    lstB = []
    for op in q:
        if int(op[0]) == 1:
            rev = rev * -1
        elif int(op[1]) * rev == 1 or int(op[1]) * rev == -2:
            lstA.append(op[2])
        elif int(op[1]) * rev == -1 or int(op[1]) * rev == 2:
            lstB.append(op[2])
    if rev == 1:
        res = "".join(lstA[::-1]) + res + "".join(lstB)
    else:
        res = "".join(lstB[::-1]) + res[::-1] + "".join(lstA)
    return res


s = eval(input())
x = int(eval(input()))
q = [input().split() for _ in range(x)]
print((main2(s, x, q)))

-from collections import deque +def main2(s, x, q): +    res = s +    rev = 1  # -1なら反転中 +    lstA = [] +    lstB = [] +    for op in q: +        if int(op[0]) == 1: +            rev = rev * -1 +        elif int(op[1]) * rev == 1 or int(op[1]) * rev == -2: +            lstA.append(op[2]) +        elif int(op[1]) * rev == -1 or int(op[1]) * rev == 2: +            lstB.append(op[2]) +    if rev == 1: +        res = "".join(lstA[::-1]) + res + "".join(lstB) +    else: +        res = "".join(lstB[::-1]) + res[::-1] + "".join(lstA) +    return res -S = input() -Q = int(input()) -query = [list(input().split()) for _ in range(Q)] -reversecount = 0 -d = deque(S) -for x in query: -    if int(x[0]) == 1: -        reversecount += 1 -    else: -        if (int(x[1]) == 1 and (reversecount % 2 == 0)) or ( -            int(x[1]) == 2 and (reversecount % 2 == 1) -        ): -            d.appendleft(x[2]) -        else: -            d.append(x[2]) -if reversecount % 2 == 1: -    d.reverse() -print(*d, sep="") + +s = eval(input()) +x = int(eval(input())) +q = [input().split() for _ in range(x)] +print((main2(s, x, q)))