S = eval(input())

L = []

R = []

rev = 0

for _ in range(int(eval(input()))):

    A = input().split()

    if A[0] == "1":

        rev ^= 1

    else:

        if (int(A[1]) ^ rev) & 1:

            L.append(A[2])

        else:

            R.append(A[2])



if rev:

    print(("".join(R[::-1]) + S[::-1] + "".join(L)))

else:

    print(("".join(L[::-1]) + S + "".join(R)))
import sys

input = lambda: sys.stdin.readline().rstrip()



S = eval(input())

L = []

R = []

rev = 0

for _ in range(int(eval(input()))):

    A = input().split()

    if A[0] == "1":

        rev ^= 1

    else:

        if (int(A[1]) ^ rev) & 1:

            L.append(A[2])

        else:

            R.append(A[2])



if rev:

    print(("".join(R[::-1]) + S[::-1] + "".join(L)))

else:

    print(("".join(L[::-1]) + S + "".join(R)))

S = eval(input())
L = []
R = []
rev = 0
for _ in range(int(eval(input()))):
    A = input().split()
    if A[0] == "1":
        rev ^= 1
    else:
        if (int(A[1]) ^ rev) & 1:
            L.append(A[2])
        else:
            R.append(A[2])
if rev:
    print(("".join(R[::-1]) + S[::-1] + "".join(L)))
else:
    print(("".join(L[::-1]) + S + "".join(R)))

import sys

input = lambda: sys.stdin.readline().rstrip()
S = eval(input())
L = []
R = []
rev = 0
for _ in range(int(eval(input()))):
    A = input().split()
    if A[0] == "1":
        rev ^= 1
    else:
        if (int(A[1]) ^ rev) & 1:
            L.append(A[2])
        else:
            R.append(A[2])
if rev:
    print(("".join(R[::-1]) + S[::-1] + "".join(L)))
else:
    print(("".join(L[::-1]) + S + "".join(R)))

+import sys + +input = lambda: sys.stdin.readline().rstrip()