from collections import deque



S = eval(input())

Q = int(eval(input()))

X = [eval(input()) for _ in range(Q)]



ans = deque(S)

r = 0  # r=0: order, r=1: reverse

for i in range(Q):

    q, *x = X[i].split()

    if q == "1":

        r = abs(r - 1)

    else:

        f, c = x

        if (r == 0 and f == "1") or (r == 1 and f == "2"):

            ans.appendleft(c)

        else:

            ans.append(c)

            

print(("".join(ans) if r == 0 else "".join(ans)[::-1]))



from collections import deque



S = eval(input())

Q = int(eval(input()))

q = deque(list(S))

rev = 0

for _ in range(Q):

    s, *x = input().split()

    if s == "1":

        rev += 1

    else:

        if ((x[0] == "1" and rev % 2 == 0)

                or (x[0] == "2" and rev % 2 == 1)):

            q.appendleft(x[1])

        else:

            q.append(x[1])



if rev % 2 == 0:

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

else:

    print(("".join(q)[::-1]))

from collections import deque

S = eval(input())
Q = int(eval(input()))
X = [eval(input()) for _ in range(Q)]
ans = deque(S)
r = 0  # r=0: order, r=1: reverse
for i in range(Q):
    q, *x = X[i].split()
    if q == "1":
        r = abs(r - 1)
    else:
        f, c = x
        if (r == 0 and f == "1") or (r == 1 and f == "2"):
            ans.appendleft(c)
        else:
            ans.append(c)
print(("".join(ans) if r == 0 else "".join(ans)[::-1]))

from collections import deque

S = eval(input())
Q = int(eval(input()))
q = deque(list(S))
rev = 0
for _ in range(Q):
    s, *x = input().split()
    if s == "1":
        rev += 1
    else:
        if (x[0] == "1" and rev % 2 == 0) or (x[0] == "2" and rev % 2 == 1):
            q.appendleft(x[1])
        else:
            q.append(x[1])
if rev % 2 == 0:
    print(("".join(q)))
else:
    print(("".join(q)[::-1]))

-X = [eval(input()) for _ in range(Q)] -ans = deque(S) -r = 0  # r=0: order, r=1: reverse -for i in range(Q): -    q, *x = X[i].split() -    if q == "1": -        r = abs(r - 1) +q = deque(list(S)) +rev = 0 +for _ in range(Q): +    s, *x = input().split() +    if s == "1": +        rev += 1 -        f, c = x -        if (r == 0 and f == "1") or (r == 1 and f == "2"): -            ans.appendleft(c) +        if (x[0] == "1" and rev % 2 == 0) or (x[0] == "2" and rev % 2 == 1): +            q.appendleft(x[1]) -            ans.append(c) -print(("".join(ans) if r == 0 else "".join(ans)[::-1])) +            q.append(x[1]) +if rev % 2 == 0: +    print(("".join(q))) +else: +    print(("".join(q)[::-1]))