from collections import deque





reverse = 0

S = deque(list(eval(input())))

q = int(eval(input()))



for _ in range(q):

    query = eval(input())

    if query[0] == '1':

        reverse = 1 - reverse

        continue



    _, f, c = query.split()

    f = int(f)

    action = (reverse + f) % 2

    if action:

        S.appendleft(c)

    else:

        S.append(c)



if reverse:

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



print((''.join(S)))
import sys

from collections import deque





reverse = 0

S = deque(list(eval(input())))

q = int(eval(input()))



for query in sys.stdin:

    if query[0] == '1':

        reverse = 1 - reverse

        continue



    _, f, c = query.split()

    f = int(f)

    action = (reverse + f) % 2

    if action:

        S.appendleft(c)

    else:

        S.append(c)



if reverse:

    S.reverse()



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

reverse = 0
S = deque(list(eval(input())))
q = int(eval(input()))
for _ in range(q):
    query = eval(input())
    if query[0] == "1":
        reverse = 1 - reverse
        continue
    _, f, c = query.split()
    f = int(f)
    action = (reverse + f) % 2
    if action:
        S.appendleft(c)
    else:
        S.append(c)
if reverse:
    S = list(S)[::-1]
print(("".join(S)))

import sys
from collections import deque

reverse = 0
S = deque(list(eval(input())))
q = int(eval(input()))
for query in sys.stdin:
    if query[0] == "1":
        reverse = 1 - reverse
        continue
    _, f, c = query.split()
    f = int(f)
    action = (reverse + f) % 2
    if action:
        S.appendleft(c)
    else:
        S.append(c)
if reverse:
    S.reverse()
print(("".join(S)))

+import sys -for _ in range(q): -    query = eval(input()) +for query in sys.stdin: -    S = list(S)[::-1] +    S.reverse()