from collections import deque

S=input()

d=deque(S)

rev=False

Q=int(input())

for i in range(Q):

    Que=input()

    if(Que=='1'):

        rev=True if not rev else False

    else:

        T,F,C=map(str,Que.split())

        if(F=='1'):

            if(not rev):

                d.appendleft(C)

            else:

                d.append(C)

        elif(F=='2'):

            if(not rev):

                d.append(C)

            else:

                d.appendleft(C)

if(not rev):

    for i in range(len(d)):

        print(d[i],end='')

else:

    for i in reversed(range(len(d))):

        print(d[i],end='')

from collections import deque

S=input()

d=deque(S)

rev=False

Q=int(input())

for i in range(Q):

    Que=input().split()

    if(Que[0]=='1'):

        rev=not rev

    else:

        if(Que[1]=='1'):

            if(not rev):

                d.appendleft(Que[2])

            else:

                d.append(Que[2])

        else:

            if(not rev):

                d.append(Que[2])

            else:

                d.appendleft(Que[2])

d=d if not rev else reversed(d)

print(*d,sep='')

from collections import deque

S = input()
d = deque(S)
rev = False
Q = int(input())
for i in range(Q):
    Que = input()
    if Que == "1":
        rev = True if not rev else False
    else:
        T, F, C = map(str, Que.split())
        if F == "1":
            if not rev:
                d.appendleft(C)
            else:
                d.append(C)
        elif F == "2":
            if not rev:
                d.append(C)
            else:
                d.appendleft(C)
if not rev:
    for i in range(len(d)):
        print(d[i], end="")
else:
    for i in reversed(range(len(d))):
        print(d[i], end="")

from collections import deque

S = input()
d = deque(S)
rev = False
Q = int(input())
for i in range(Q):
    Que = input().split()
    if Que[0] == "1":
        rev = not rev
    else:
        if Que[1] == "1":
            if not rev:
                d.appendleft(Que[2])
            else:
                d.append(Que[2])
        else:
            if not rev:
                d.append(Que[2])
            else:
                d.appendleft(Que[2])
d = d if not rev else reversed(d)
print(*d, sep="")

-    Que = input() -    if Que == "1": -        rev = True if not rev else False +    Que = input().split() +    if Que[0] == "1": +        rev = not rev -        T, F, C = map(str, Que.split()) -        if F == "1": +        if Que[1] == "1": -                d.appendleft(C) +                d.appendleft(Que[2]) -                d.append(C) -        elif F == "2": +                d.append(Que[2]) +        else: -                d.append(C) +                d.append(Que[2]) -                d.appendleft(C) -if not rev: -    for i in range(len(d)): -        print(d[i], end="") -else: -    for i in reversed(range(len(d))): -        print(d[i], end="") +                d.appendleft(Que[2]) +d = d if not rev else reversed(d) +print(*d, sep="")