from collections import deque

import sys



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



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

q = int(eval(input()))



rev_cnt = 0

for i in range(q):

    query = input().split()

    if query[0] == '2':

        if (query[1] == '1' and rev_cnt % 2 == 0) or ((query[1] == '2' and rev_cnt % 2 == 1)):

            s.appendleft(query[2])

        else:

            s.append(query[2])

    else:

        rev_cnt += 1



if rev_cnt % 2 == 1:

    print((''.join([s[len(s) - i - 1] for i in range(len(s))])))

else:

    print((''.join([c for c in s])))

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)

from collections import deque
import sys

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

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)

-rev_cnt = 0 +is_reverse = False -        if (query[1] == "1" and rev_cnt % 2 == 0) or ( -            (query[1] == "2" and rev_cnt % 2 == 1) -        ): +        if (query[1] == "1" and not is_reverse) or (query[1] == "2" and is_reverse): -        rev_cnt += 1 -if rev_cnt % 2 == 1: -    print(("".join([s[len(s) - i - 1] for i in range(len(s))]))) +        is_reverse = not is_reverse +result = "".join(s) +if is_reverse: +    print((result[::-1])) -    print(("".join([c for c in s]))) +    print(result)