from collections import deque

import sys



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



s = deque(list(eval(input())))

q = int(eval(input()))



is_reverse = False

for i in range(q):

    query = input().split()

    if query[0] == '2':

        if (query[1] == '1' and not is_reverse) or (query[1] == '2' and is_reverse):

            s.appendleft(query[2])

        else:

            s.append(query[2])

    else:

        is_reverse = not is_reverse



result = ''.join(s)

if is_reverse:

    print((result[::-1]))

else:

    print(result)

import sys

from collections import deque





def input():

    return sys.stdin.readline().strip()





S = eval(input())

Q = int(eval(input()))

q = deque(S)

flipped = False

for _ in range(Q):

    q_t, *q_d = input().split()

    if q_t == "1":

        flipped = not flipped

    else:

        F, C = q_d

        if (not flipped and F == "2") or (flipped and F == "1"):

            q.append(C)

        else:

            q.appendleft(C)



ans = list(q)

if flipped:

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

else:

    print(("".join(ans)))

from collections import deque
import sys

input = lambda: sys.stdin.readline().rstrip()
s = deque(list(eval(input())))
q = int(eval(input()))
is_reverse = False
for i in range(q):
    query = input().split()
    if query[0] == "2":
        if (query[1] == "1" and not is_reverse) or (query[1] == "2" and is_reverse):
            s.appendleft(query[2])
        else:
            s.append(query[2])
    else:
        is_reverse = not is_reverse
result = "".join(s)
if is_reverse:
    print((result[::-1]))
else:
    print(result)

import sys
from collections import deque


def input():
    return sys.stdin.readline().strip()


S = eval(input())
Q = int(eval(input()))
q = deque(S)
flipped = False
for _ in range(Q):
    q_t, *q_d = input().split()
    if q_t == "1":
        flipped = not flipped
    else:
        F, C = q_d
        if (not flipped and F == "2") or (flipped and F == "1"):
            q.append(C)
        else:
            q.appendleft(C)
ans = list(q)
if flipped:
    print(("".join(ans[::-1])))
else:
    print(("".join(ans)))

+import sys -import sys -input = lambda: sys.stdin.readline().rstrip() -s = deque(list(eval(input()))) -q = int(eval(input())) -is_reverse = False -for i in range(q): -    query = input().split() -    if query[0] == "2": -        if (query[1] == "1" and not is_reverse) or (query[1] == "2" and is_reverse): -            s.appendleft(query[2]) + +def input(): +    return sys.stdin.readline().strip() + + +S = eval(input()) +Q = int(eval(input())) +q = deque(S) +flipped = False +for _ in range(Q): +    q_t, *q_d = input().split() +    if q_t == "1": +        flipped = not flipped +    else: +        F, C = q_d +        if (not flipped and F == "2") or (flipped and F == "1"): +            q.append(C) -            s.append(query[2]) -    else: -        is_reverse = not is_reverse -result = "".join(s) -if is_reverse: -    print((result[::-1])) +            q.appendleft(C) +ans = list(q) +if flipped: +    print(("".join(ans[::-1]))) -    print(result) +    print(("".join(ans)))