'''

　 ∧_,,∧    究極奥義「WAがACになーれ！！」

　（`・ω・)つ━☆・*。

　⊂　　 ノ 　　　・゜+.

　 し’´Ｊ　　*・ 

'''

s=input()

a=[]

b=[]

now=1

q=int(input())

for i in range(q):

    x=list(input().split())

    if x[0]=="1":

        now*=-1

    else:

        if now==1 and x[1]=="2" or now==-1 and x[1]=="1":

            b.append(x[2])

        else:

            a.append(x[2])

if now==-1:

    ans=b[::-1]+list(s[::-1])+a

    print(*ans,sep="")

else:

    ans=a[::-1]+list(s)+b

    print(*ans,sep="")

s=input()

a=[]

b=[]

now=True

q=int(input())

for i in range(q):

    x=list(input().split())

    if x[0]=="1":

        now=not now

    else:

        if now and x[1]=="2" or not now and x[1]=="1":

            b.append(x[2])

        else:

            a.append(x[2])

if now:

    ans=a[::-1]+list(s)+b

else:

    ans=b[::-1]+list(s[::-1])+a

print(*ans,sep="")

"""
　 ∧_,,∧    究極奥義「WAがACになーれ！！」
　（`・ω・)つ━☆・*。
　⊂　　 ノ 　　　・゜+.
　 し’´Ｊ　　*・ 
"""
s = input()
a = []
b = []
now = 1
q = int(input())
for i in range(q):
    x = list(input().split())
    if x[0] == "1":
        now *= -1
    else:
        if now == 1 and x[1] == "2" or now == -1 and x[1] == "1":
            b.append(x[2])
        else:
            a.append(x[2])
if now == -1:
    ans = b[::-1] + list(s[::-1]) + a
    print(*ans, sep="")
else:
    ans = a[::-1] + list(s) + b
    print(*ans, sep="")

s = input()
a = []
b = []
now = True
q = int(input())
for i in range(q):
    x = list(input().split())
    if x[0] == "1":
        now = not now
    else:
        if now and x[1] == "2" or not now and x[1] == "1":
            b.append(x[2])
        else:
            a.append(x[2])
if now:
    ans = a[::-1] + list(s) + b
else:
    ans = b[::-1] + list(s[::-1]) + a
print(*ans, sep="")

-""" -　 ∧_,,∧    究極奥義「WAがACになーれ！！」 -　（`・ω・)つ━☆・*。 -　⊂　　 ノ 　　　・゜+. -　 し’´Ｊ　　*・ -""" -now = 1 +now = True -        now *= -1 +        now = not now -        if now == 1 and x[1] == "2" or now == -1 and x[1] == "1": +        if now and x[1] == "2" or not now and x[1] == "1": -if now == -1: +if now: +    ans = a[::-1] + list(s) + b +else: -    print(*ans, sep="") -else: -    ans = a[::-1] + list(s) + b -    print(*ans, sep="") +print(*ans, sep="")