# D - String Formation

from collections import deque

s = deque(input())

q = int(input())

odd = 0

for i in range(q):

    t,*fc = input().split()

    if t=='1': odd ^= 1 #t1

    else: #t2

        if odd ^ (int(fc[0])-1): s.append(fc[1])

        else: s.appendleft(fc[1])

if odd: deque.reverse(s)

print(*s, sep='')

# D - String Formation

from collections import deque

s = deque(eval(input()))

q = int(eval(input()))

odd = 0

for i in range(q):

    t,*fc = input().split()

    if t=='1': odd ^= 1 #t1

    else: #t2

        if odd ^ (int(fc[0])-1): s.append(fc[1])

        else: s.appendleft(fc[1])

if odd: deque.reverse(s)

print((''.join(s)))
# D - String Formation
from collections import deque

s = deque(input())
q = int(input())
odd = 0
for i in range(q):
    t, *fc = input().split()
    if t == "1":
        odd ^= 1  # t1
    else:  # t2
        if odd ^ (int(fc[0]) - 1):
            s.append(fc[1])
        else:
            s.appendleft(fc[1])
if odd:
    deque.reverse(s)
print(*s, sep="")

# D - String Formation
from collections import deque

s = deque(eval(input()))
q = int(eval(input()))
odd = 0
for i in range(q):
    t, *fc = input().split()
    if t == "1":
        odd ^= 1  # t1
    else:  # t2
        if odd ^ (int(fc[0]) - 1):
            s.append(fc[1])
        else:
            s.appendleft(fc[1])
if odd:
    deque.reverse(s)
print(("".join(s)))

-s = deque(input()) -q = int(input()) +s = deque(eval(input())) +q = int(eval(input())) -print(*s, sep="") +print(("".join(s)))