from collections import deque

S = deque(list(input().strip()))

Q = int(eval(input()))

cnt = 0

for i in range(Q):

    q = list(input().split())

    if len(q)==1:

        cnt += 1

    else:

        F = int(q[1])

        C = q[2]

        if cnt%2==0:

            if F==1:

                S.appendleft(C)

            else:

                S.append(C)

        else:

            if F==1:

                S.append(C)

            else:

                S.appendleft(C)

if cnt%2==0:

    print(("".join(S)))

else:

    S = list(S)[::-1]

    print(("".join(S)))
from collections import deque

S = deque(list(input().strip()))

Q = int(eval(input()))

P = 0

for _ in range(Q):

    q = list(input().split())

    if q[0]=="1":

        P += 1

        P = P%2

    else:

        c = q[2]

        if q[1]=="1":

            if P==0:

                S.appendleft(c)

            else:

                S.append(c)

        else:

            if P==0:

                S.append(c)

            else:

                S.appendleft(c)

if P==1:

    S = list(S)

    S = S[::-1]

print(("".join(S)))
from collections import deque

S = deque(list(input().strip()))
Q = int(eval(input()))
cnt = 0
for i in range(Q):
    q = list(input().split())
    if len(q) == 1:
        cnt += 1
    else:
        F = int(q[1])
        C = q[2]
        if cnt % 2 == 0:
            if F == 1:
                S.appendleft(C)
            else:
                S.append(C)
        else:
            if F == 1:
                S.append(C)
            else:
                S.appendleft(C)
if cnt % 2 == 0:
    print(("".join(S)))
else:
    S = list(S)[::-1]
    print(("".join(S)))

from collections import deque

S = deque(list(input().strip()))
Q = int(eval(input()))
P = 0
for _ in range(Q):
    q = list(input().split())
    if q[0] == "1":
        P += 1
        P = P % 2
    else:
        c = q[2]
        if q[1] == "1":
            if P == 0:
                S.appendleft(c)
            else:
                S.append(c)
        else:
            if P == 0:
                S.append(c)
            else:
                S.appendleft(c)
if P == 1:
    S = list(S)
    S = S[::-1]
print(("".join(S)))

-cnt = 0 -for i in range(Q): +P = 0 +for _ in range(Q): -    if len(q) == 1: -        cnt += 1 +    if q[0] == "1": +        P += 1 +        P = P % 2 -        F = int(q[1]) -        C = q[2] -        if cnt % 2 == 0: -            if F == 1: -                S.appendleft(C) +        c = q[2] +        if q[1] == "1": +            if P == 0: +                S.appendleft(c) -                S.append(C) +                S.append(c) -            if F == 1: -                S.append(C) +            if P == 0: +                S.append(c) -                S.appendleft(C) -if cnt % 2 == 0: -    print(("".join(S))) -else: -    S = list(S)[::-1] -    print(("".join(S))) +                S.appendleft(c) +if P == 1: +    S = list(S) +    S = S[::-1] +print(("".join(S)))