#前・左につける変数、後ろ・右につける変数を用意して最後に足す

#前・左は最後にひっくり返す（abc ⇒cba)



#初期入力

import sys

input = sys.stdin.readline

S = input()

S=S.strip("\n")

Q = int(input())

FQ_dic={}

for i in range(Q):

    FQ_dic[i] =input().split()



rev =0

front =""

back =""



for i in range(Q):

   # print(S) 



    if FQ_dic[i][0] =="1": #逆転する

                rev +=1

    else:                   #逆転なし  

        if FQ_dic[i][1]=="1":     #前=左につける 

            if rev %2 ==0:

                front += FQ_dic[i][2]

            else:

                back  += FQ_dic[i][2]  

        else: #                      #後ろ=右につける

            if rev %2 ==0:

                back  += FQ_dic[i][2]  

            else:        

                front += FQ_dic[i][2]

front =front[::-1]

S =front + S + back



if rev %2 ==0:

    print(*S,sep="")

else:

    print(*S[::-1],sep="")

# deque で高速に文字を先頭でもたせる



#初期入力

from collections import deque

import sys

input = sys.stdin.readline

S = input().strip()

Q = int(eval(input()))

FQ_dic={}

for i in range(Q):

    FQ_dic[i] =input().split()



rev =0 #反転Flag

dq =deque(S)

for i in range(Q):

    if FQ_dic[i][0] =="1":

        rev +=1

    else:

        a,b,c =FQ_dic[i]

        if rev %2 ==0 and b =="1"  :

            dq.appendleft(c)

        elif rev %2 ==0 and b =="2":

            dq.append(c)

        elif rev %2 ==1 and b =="1":

            dq.append(c)

        elif rev %2 ==1 and b =="2":

            dq.appendleft(c)

if rev %2 ==1:

    dq.reverse()

ans ="".join(dq)

print(ans)
# 前・左につける変数、後ろ・右につける変数を用意して最後に足す
# 前・左は最後にひっくり返す（abc ⇒cba)
# 初期入力
import sys

input = sys.stdin.readline
S = input()
S = S.strip("\n")
Q = int(input())
FQ_dic = {}
for i in range(Q):
    FQ_dic[i] = input().split()
rev = 0
front = ""
back = ""
for i in range(Q):
    # print(S)
    if FQ_dic[i][0] == "1":  # 逆転する
        rev += 1
    else:  # 逆転なし
        if FQ_dic[i][1] == "1":  # 前=左につける
            if rev % 2 == 0:
                front += FQ_dic[i][2]
            else:
                back += FQ_dic[i][2]
        else:  #                      #後ろ=右につける
            if rev % 2 == 0:
                back += FQ_dic[i][2]
            else:
                front += FQ_dic[i][2]
front = front[::-1]
S = front + S + back
if rev % 2 == 0:
    print(*S, sep="")
else:
    print(*S[::-1], sep="")

# deque で高速に文字を先頭でもたせる
# 初期入力
from collections import deque
import sys

input = sys.stdin.readline
S = input().strip()
Q = int(eval(input()))
FQ_dic = {}
for i in range(Q):
    FQ_dic[i] = input().split()
rev = 0  # 反転Flag
dq = deque(S)
for i in range(Q):
    if FQ_dic[i][0] == "1":
        rev += 1
    else:
        a, b, c = FQ_dic[i]
        if rev % 2 == 0 and b == "1":
            dq.appendleft(c)
        elif rev % 2 == 0 and b == "2":
            dq.append(c)
        elif rev % 2 == 1 and b == "1":
            dq.append(c)
        elif rev % 2 == 1 and b == "2":
            dq.appendleft(c)
if rev % 2 == 1:
    dq.reverse()
ans = "".join(dq)
print(ans)

-# 前・左につける変数、後ろ・右につける変数を用意して最後に足す -# 前・左は最後にひっくり返す（abc ⇒cba) +# deque で高速に文字を先頭でもたせる +from collections import deque -S = input() -S = S.strip("\n") -Q = int(input()) +S = input().strip() +Q = int(eval(input())) -rev = 0 -front = "" -back = "" +rev = 0  # 反転Flag +dq = deque(S) -    # print(S) -    if FQ_dic[i][0] == "1":  # 逆転する +    if FQ_dic[i][0] == "1": -    else:  # 逆転なし -        if FQ_dic[i][1] == "1":  # 前=左につける -            if rev % 2 == 0: -                front += FQ_dic[i][2] -            else: -                back += FQ_dic[i][2] -        else:  #                      #後ろ=右につける -            if rev % 2 == 0: -                back += FQ_dic[i][2] -            else: -                front += FQ_dic[i][2] -front = front[::-1] -S = front + S + back -if rev % 2 == 0: -    print(*S, sep="") -else: -    print(*S[::-1], sep="") +    else: +        a, b, c = FQ_dic[i] +        if rev % 2 == 0 and b == "1": +            dq.appendleft(c) +        elif rev % 2 == 0 and b == "2": +            dq.append(c) +        elif rev % 2 == 1 and b == "1": +            dq.append(c) +        elif rev % 2 == 1 and b == "2": +            dq.appendleft(c) +if rev % 2 == 1: +    dq.reverse() +ans = "".join(dq) +print(ans)