from collections import deque

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

Q = int(eval(input()))

cnt = 0

for _ in range(Q):

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

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

        cnt += 1

    else:

        if cnt%2==0:

            if int(q[1])==1:

                S.appendleft(q[2])

            else:

                S.append(q[2])

        else:

            if int(q[1])==1:

                S.append(q[2])

            else:

                S.appendleft(q[2])

if cnt%2==0:

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

else:

    S.reverse()

    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()))
cnt = 0
for _ in range(Q):
    q = list(input().split())
    if int(q[0]) == 1:
        cnt += 1
    else:
        if cnt % 2 == 0:
            if int(q[1]) == 1:
                S.appendleft(q[2])
            else:
                S.append(q[2])
        else:
            if int(q[1]) == 1:
                S.append(q[2])
            else:
                S.appendleft(q[2])
if cnt % 2 == 0:
    print(("".join(S)))
else:
    S.reverse()
    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)))

-for _ in range(Q): +for i in range(Q): -    if int(q[0]) == 1: +    if len(q) == 1: +        F = int(q[1]) +        C = q[2] -            if int(q[1]) == 1: -                S.appendleft(q[2]) +            if F == 1: +                S.appendleft(C) -                S.append(q[2]) +                S.append(C) -            if int(q[1]) == 1: -                S.append(q[2]) +            if F == 1: +                S.append(C) -                S.appendleft(q[2]) +                S.appendleft(C) -    S.reverse() +    S = list(S)[::-1]