import sys



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

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



S = sr()

Q = ir()

dir = 0 #最初の向きを0、逆向きを1

head_tail = ['', '']

for _ in range(Q):

    x = sr().split()

    if x[0] == '1':

        dir = (1 - dir)

    else:

        t, f, c = x

        h_d = dir

        if f == '2':

            h_d = (1 - h_d)

        head_tail[h_d] += c



if dir == 0:

    answer = head_tail[0][::-1] + S + head_tail[1]

else:

    answer = head_tail[1][::-1] + S[::-1] + head_tail[0]



print(answer)

# coding: utf-8

import sys



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

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



S = sr()

Q = ir()

rev = 0

top = ''

tail = ''

# xor

for _ in range(Q):

    x = sr().split()

    if x[0] == '1':

        rev ^= 1

    else:

        _, f, c = x

        if (int(f)^rev) & 1:

            top += c

        else:

            tail += c



answer = top[::-1] + S + tail

if rev&1:

    answer = answer[::-1]

print(answer)

# 40

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
S = sr()
Q = ir()
dir = 0  # 最初の向きを0、逆向きを1
head_tail = ["", ""]
for _ in range(Q):
    x = sr().split()
    if x[0] == "1":
        dir = 1 - dir
    else:
        t, f, c = x
        h_d = dir
        if f == "2":
            h_d = 1 - h_d
        head_tail[h_d] += c
if dir == 0:
    answer = head_tail[0][::-1] + S + head_tail[1]
else:
    answer = head_tail[1][::-1] + S[::-1] + head_tail[0]
print(answer)

# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
S = sr()
Q = ir()
rev = 0
top = ""
tail = ""
# xor
for _ in range(Q):
    x = sr().split()
    if x[0] == "1":
        rev ^= 1
    else:
        _, f, c = x
        if (int(f) ^ rev) & 1:
            top += c
        else:
            tail += c
answer = top[::-1] + S + tail
if rev & 1:
    answer = answer[::-1]
print(answer)
# 40

+# coding: utf-8 -dir = 0  # 最初の向きを0、逆向きを1 -head_tail = ["", ""] +rev = 0 +top = "" +tail = "" +# xor -        dir = 1 - dir +        rev ^= 1 -        t, f, c = x -        h_d = dir -        if f == "2": -            h_d = 1 - h_d -        head_tail[h_d] += c -if dir == 0: -    answer = head_tail[0][::-1] + S + head_tail[1] -else: -    answer = head_tail[1][::-1] + S[::-1] + head_tail[0] +        _, f, c = x +        if (int(f) ^ rev) & 1: +            top += c +        else: +            tail += c +answer = top[::-1] + S + tail +if rev & 1: +    answer = answer[::-1] +# 40