from collections import deque


S = deque(input())
Q = int(input())
is_reversed = False

for _ in range(Q):
    Query = input().split()
    if Query[0] == "1":
        is_reversed = not is_reversed
    else:
        F, C = int(Query[1]), Query[2]
        if is_reversed:
            F = 3 - F
        if F == 1:
                S.appendleft(C)
        else:
                S.append(C)

if is_reversed:
    S.reverse()
print("".join(S))

dc9c00b44b8357f4763dead42c13601ed5b7b3c6
<mask token>

<mask token>
for _ in range(Q):
    Query = input().split()
    if Query[0] == '1':
        is_reversed = not is_reversed
    else:
        F, C = int(Query[1]), Query[2]
        if is_reversed:
            F = 3 - F
        if F == 1:
            S.appendleft(C)
        else:
            S.append(C)
if is_reversed:
    S.reverse()
print(''.join(S))

<mask token>
S = deque(input())
Q = int(input())
is_reversed = False
for _ in range(Q):
    Query = input().split()
    if Query[0] == '1':
        is_reversed = not is_reversed
    else:
        F, C = int(Query[1]), Query[2]
        if is_reversed:
            F = 3 - F
        if F == 1:
            S.appendleft(C)
        else:
            S.append(C)
if is_reversed:
    S.reverse()
print(''.join(S))

from collections import deque
S = deque(input())
Q = int(input())
is_reversed = False
for _ in range(Q):
    Query = input().split()
    if Query[0] == '1':
        is_reversed = not is_reversed
    else:
        F, C = int(Query[1]), Query[2]
        if is_reversed:
            F = 3 - F
        if F == 1:
            S.appendleft(C)
        else:
            S.append(C)
if is_reversed:
    S.reverse()
print(''.join(S))

from collections import deque


S = deque(input())
Q = int(input())
is_reversed = False

for _ in range(Q):
    Query = input().split()
    if Query[0] == "1":
        is_reversed = not is_reversed
    else:
        F, C = int(Query[1]), Query[2]
        if is_reversed:
            F = 3 - F
        if F == 1:
                S.appendleft(C)
        else:
                S.append(C)

if is_reversed:
    S.reverse()
print("".join(S))
