S=eval(input())

Q=int(eval(input()))



R=0

S1=""

S2=""

for i in range(Q):

    temp=list(input().split())



    if int(temp[0])==1:

        S=S1+S+S2

        S1=""

        S2=""

        R+=1

    elif int(temp[0])==2:

        F=int(temp[1])

        c=temp[2]

        if F==1:

            if R%2==0:

                S1=c+S1

            else:

                S2=S2+c

        elif F==2:

            if R%2==0:

                S2=S2+c

            else:

                S1=c+S1

S=S1+S+S2



if R%2==1:

    ans=S[-1::-1]

    print(ans)

else:

    print(S)



from collections import deque



S=eval(input())

Q=int(eval(input()))



R=0

S=deque(S)



for i in range(Q):

    temp=list(input().split())

    if int(temp[0])==1:

        R+=1

    elif int(temp[0])==2:

        F=int(temp[1])

        c=temp[2]

        if F==1:

            if R%2==0:

                S.appendleft(c)

            else:

                S.append(c)

        elif F==2:

            if R%2==0:

                S.append(c)

            else:

                S.appendleft(c)



if R%2==1:

    S=list(S)

    ans=S[-1::-1]

    ans=list(map(str,ans))

else:

    ans=list(map(str,S))



print(("".join(ans)))







S = eval(input())
Q = int(eval(input()))
R = 0
S1 = ""
S2 = ""
for i in range(Q):
    temp = list(input().split())
    if int(temp[0]) == 1:
        S = S1 + S + S2
        S1 = ""
        S2 = ""
        R += 1
    elif int(temp[0]) == 2:
        F = int(temp[1])
        c = temp[2]
        if F == 1:
            if R % 2 == 0:
                S1 = c + S1
            else:
                S2 = S2 + c
        elif F == 2:
            if R % 2 == 0:
                S2 = S2 + c
            else:
                S1 = c + S1
S = S1 + S + S2
if R % 2 == 1:
    ans = S[-1::-1]
    print(ans)
else:
    print(S)

from collections import deque

S = eval(input())
Q = int(eval(input()))
R = 0
S = deque(S)
for i in range(Q):
    temp = list(input().split())
    if int(temp[0]) == 1:
        R += 1
    elif int(temp[0]) == 2:
        F = int(temp[1])
        c = temp[2]
        if F == 1:
            if R % 2 == 0:
                S.appendleft(c)
            else:
                S.append(c)
        elif F == 2:
            if R % 2 == 0:
                S.append(c)
            else:
                S.appendleft(c)
if R % 2 == 1:
    S = list(S)
    ans = S[-1::-1]
    ans = list(map(str, ans))
else:
    ans = list(map(str, S))
print(("".join(ans)))

+from collections import deque + -S1 = "" -S2 = "" +S = deque(S) -        S = S1 + S + S2 -        S1 = "" -        S2 = "" -                S1 = c + S1 +                S.appendleft(c) -                S2 = S2 + c +                S.append(c) -                S2 = S2 + c +                S.append(c) -                S1 = c + S1 -S = S1 + S + S2 +                S.appendleft(c) +    S = list(S) -    print(ans) +    ans = list(map(str, ans)) -    print(S) +    ans = list(map(str, S)) +print(("".join(ans)))