from collections import deque

ss=deque()

s=list(eval(input()))

l=len(s)

for i in range(l):

    ss.append(s[i])

q=int(eval(input()))

info=[]

rev=[] #i回までに何回反転があるか

num=0

for i in range(q):

    info.append(list(input().split()))

moji=0 #文字の追加数

for i in range(q):

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

        num+=1

    else:

        if info[i][1]=="2":

            rev.append([info[i][2],2,num]) #末尾

        else:

            rev.append([info[i][2],1,num])

        moji+=1

if num%2==1:

    ss.reverse()

#print(rev)

#print(num)

for i in range(moji):

    now=rev[i][1]

    if (num-rev[i][2])%2==1: #これが奇数だと２なら先頭になる

        #print("change")

        if rev[i][1]==2:

            rev[i][1]=1

        else:

            rev[i][1]=2

    if rev[i][1]==2:

        ss.append(rev[i][0])

    else:

        ss.appendleft(rev[i][0])

print(("".join(ss)))

#print(rev)
from collections import deque



s=eval(input())

q=int(eval(input()))

count=0 #何回反転があるか

ss=deque(s)

flag=True #通常状態

for i in range(q):

    info=eval(input())

    if info[0]=="1":

        count+=1

        if flag:

            flag=False

        else:

            flag=True

    else:

        _,f,c=info.split()

        if flag:

            if f=="1":

                ss.appendleft(c)

            else:

                ss.append(c)

        else: #反転状態

            if f=="1":

                ss.append(c)

            else:

                ss.appendleft(c)

ans="".join(ss)

print((ans if count%2==0 else ans[::-1]))
from collections import deque

ss = deque()
s = list(eval(input()))
l = len(s)
for i in range(l):
    ss.append(s[i])
q = int(eval(input()))
info = []
rev = []  # i回までに何回反転があるか
num = 0
for i in range(q):
    info.append(list(input().split()))
moji = 0  # 文字の追加数
for i in range(q):
    if info[i][0] == "1":
        num += 1
    else:
        if info[i][1] == "2":
            rev.append([info[i][2], 2, num])  # 末尾
        else:
            rev.append([info[i][2], 1, num])
        moji += 1
if num % 2 == 1:
    ss.reverse()
# print(rev)
# print(num)
for i in range(moji):
    now = rev[i][1]
    if (num - rev[i][2]) % 2 == 1:  # これが奇数だと２なら先頭になる
        # print("change")
        if rev[i][1] == 2:
            rev[i][1] = 1
        else:
            rev[i][1] = 2
    if rev[i][1] == 2:
        ss.append(rev[i][0])
    else:
        ss.appendleft(rev[i][0])
print(("".join(ss)))
# print(rev)

from collections import deque

s = eval(input())
q = int(eval(input()))
count = 0  # 何回反転があるか
ss = deque(s)
flag = True  # 通常状態
for i in range(q):
    info = eval(input())
    if info[0] == "1":
        count += 1
        if flag:
            flag = False
        else:
            flag = True
    else:
        _, f, c = info.split()
        if flag:
            if f == "1":
                ss.appendleft(c)
            else:
                ss.append(c)
        else:  # 反転状態
            if f == "1":
                ss.append(c)
            else:
                ss.appendleft(c)
ans = "".join(ss)
print((ans if count % 2 == 0 else ans[::-1]))

-ss = deque() -s = list(eval(input())) -l = len(s) -for i in range(l): -    ss.append(s[i]) +s = eval(input()) -info = [] -rev = []  # i回までに何回反転があるか -num = 0 +count = 0  # 何回反転があるか +ss = deque(s) +flag = True  # 通常状態 -    info.append(list(input().split())) -moji = 0  # 文字の追加数 -for i in range(q): -    if info[i][0] == "1": -        num += 1 +    info = eval(input()) +    if info[0] == "1": +        count += 1 +        if flag: +            flag = False +        else: +            flag = True -        if info[i][1] == "2": -            rev.append([info[i][2], 2, num])  # 末尾 -        else: -            rev.append([info[i][2], 1, num]) -        moji += 1 -if num % 2 == 1: -    ss.reverse() -# print(rev) -# print(num) -for i in range(moji): -    now = rev[i][1] -    if (num - rev[i][2]) % 2 == 1:  # これが奇数だと２なら先頭になる -        # print("change") -        if rev[i][1] == 2: -            rev[i][1] = 1 -        else: -            rev[i][1] = 2 -    if rev[i][1] == 2: -        ss.append(rev[i][0]) -    else: -        ss.appendleft(rev[i][0]) -print(("".join(ss))) -# print(rev) +        _, f, c = info.split() +        if flag: +            if f == "1": +                ss.appendleft(c) +            else: +                ss.append(c) +        else:  # 反転状態 +            if f == "1": +                ss.append(c) +            else: +                ss.appendleft(c) +ans = "".join(ss) +print((ans if count % 2 == 0 else ans[::-1]))