S=eval(input())

Q=int(eval(input()))

x=0

A=[]

B=[]

for i in range(0,Q):

    query=list(input().split())

    if query[0]=='1':

        x+=1

    else:

        if query[1]=='1':

            if x%2==1:

                B.append(query[2])

            else:

                A.append(query[2])

        else:

            if x%2==1:

                A.append(query[2])

            else:

                B.append(query[2])



if x%2==1:

    B=[B[len(B)-1-i] for i in range(0,len(B))]

    S=[S[len(S)-1-i] for i in range(0,len(S))]

    a=''.join(A)

    b=''.join(B)

    S=''.join(S)

    print((b+S+a))

else:

    A=[A[len(A)-1-i] for i in range(0,len(A))]

    a=''.join(A)

    b=''.join(B)

    print((a+S+b))
from collections import deque

import sys



input=sys.stdin.readline



S=input().rstrip()



string = deque([S[i] for i in range(len(S))])



reverse = False



for _ in range(int(eval(input()))):

    q = input().rstrip().split()



    if q[0] == "1":

        reverse = not reverse



    else:

        if q[1] == "1":

            if reverse:

                string.append(q[2])

            else:

                string.appendleft(q[2])



        else:

            if reverse:

                string.appendleft(q[2])

            else:

                string.append(q[2])



string = list(string)



if reverse:

    string = string[::-1]



print(("".join(string)))

S = eval(input())
Q = int(eval(input()))
x = 0
A = []
B = []
for i in range(0, Q):
    query = list(input().split())
    if query[0] == "1":
        x += 1
    else:
        if query[1] == "1":
            if x % 2 == 1:
                B.append(query[2])
            else:
                A.append(query[2])
        else:
            if x % 2 == 1:
                A.append(query[2])
            else:
                B.append(query[2])
if x % 2 == 1:
    B = [B[len(B) - 1 - i] for i in range(0, len(B))]
    S = [S[len(S) - 1 - i] for i in range(0, len(S))]
    a = "".join(A)
    b = "".join(B)
    S = "".join(S)
    print((b + S + a))
else:
    A = [A[len(A) - 1 - i] for i in range(0, len(A))]
    a = "".join(A)
    b = "".join(B)
    print((a + S + b))

from collections import deque
import sys

input = sys.stdin.readline
S = input().rstrip()
string = deque([S[i] for i in range(len(S))])
reverse = False
for _ in range(int(eval(input()))):
    q = input().rstrip().split()
    if q[0] == "1":
        reverse = not reverse
    else:
        if q[1] == "1":
            if reverse:
                string.append(q[2])
            else:
                string.appendleft(q[2])
        else:
            if reverse:
                string.appendleft(q[2])
            else:
                string.append(q[2])
string = list(string)
if reverse:
    string = string[::-1]
print(("".join(string)))

-S = eval(input()) -Q = int(eval(input())) -x = 0 -A = [] -B = [] -for i in range(0, Q): -    query = list(input().split()) -    if query[0] == "1": -        x += 1 +from collections import deque +import sys + +input = sys.stdin.readline +S = input().rstrip() +string = deque([S[i] for i in range(len(S))]) +reverse = False +for _ in range(int(eval(input()))): +    q = input().rstrip().split() +    if q[0] == "1": +        reverse = not reverse -        if query[1] == "1": -            if x % 2 == 1: -                B.append(query[2]) +        if q[1] == "1": +            if reverse: +                string.append(q[2]) -                A.append(query[2]) +                string.appendleft(q[2]) -            if x % 2 == 1: -                A.append(query[2]) +            if reverse: +                string.appendleft(q[2]) -                B.append(query[2]) -if x % 2 == 1: -    B = [B[len(B) - 1 - i] for i in range(0, len(B))] -    S = [S[len(S) - 1 - i] for i in range(0, len(S))] -    a = "".join(A) -    b = "".join(B) -    S = "".join(S) -    print((b + S + a)) -else: -    A = [A[len(A) - 1 - i] for i in range(0, len(A))] -    a = "".join(A) -    b = "".join(B) -    print((a + S + b)) +                string.append(q[2]) +string = list(string) +if reverse: +    string = string[::-1] +print(("".join(string)))