



def I(): return int(eval(input()))

def MI(): return list(map(int, input().split()))

def LI(): return list(map(int, input().split()))

from collections import deque





def main():

    mod=10**9+7

    S=deque(eval(input()))

    Q=I()

    dir=0#0で手前につける

    

    for _ in range(Q):

        q=list(input().split())

        if q[0]=="1":

            dir+=1

            dir%=2

        else:

            dir2=dir

            if q[1]=="2":

                dir2+=1

                dir2%=2

            if dir2==0:

                S.appendleft(q[2])

            else:

                S.append(q[2])

            

    ans=list(S)

    

    if dir==1:

        ans=ans[::-1]

        

    print((''.join(map(str, ans))))

        



main()





def I(): return int(eval(input()))

def MI(): return list(map(int, input().split()))

def LI(): return list(map(int, input().split()))

from collections import deque





def main():

    mod=10**9+7

    S=eval(input())

    

    from collections import deque

    dq=deque()

    

    for c in S:

        dq.appendleft(c)

        

    rev=0

    Q=I()

    for _ in range(Q):

        q=input().split()

        if q[0]=="1":

            rev=(rev+1)%2

        else:

            f=int(q[1])

            c=q[2]

            

            if (rev+f)%2==1:

                dq.append(c)

            else:

                dq.appendleft(c)

                

    ans=[]

    if rev:

        while dq:

            ans.append(dq.popleft())

    else:

        while dq:

            ans.append(dq.pop())

            

    print((''.join(map(str, ans))))

        



        



main()

def I():
    return int(eval(input()))


def MI():
    return list(map(int, input().split()))


def LI():
    return list(map(int, input().split()))


from collections import deque


def main():
    mod = 10**9 + 7
    S = deque(eval(input()))
    Q = I()
    dir = 0  # 0で手前につける
    for _ in range(Q):
        q = list(input().split())
        if q[0] == "1":
            dir += 1
            dir %= 2
        else:
            dir2 = dir
            if q[1] == "2":
                dir2 += 1
                dir2 %= 2
            if dir2 == 0:
                S.appendleft(q[2])
            else:
                S.append(q[2])
    ans = list(S)
    if dir == 1:
        ans = ans[::-1]
    print(("".join(map(str, ans))))


main()

def I():
    return int(eval(input()))


def MI():
    return list(map(int, input().split()))


def LI():
    return list(map(int, input().split()))


from collections import deque


def main():
    mod = 10**9 + 7
    S = eval(input())
    from collections import deque

    dq = deque()
    for c in S:
        dq.appendleft(c)
    rev = 0
    Q = I()
    for _ in range(Q):
        q = input().split()
        if q[0] == "1":
            rev = (rev + 1) % 2
        else:
            f = int(q[1])
            c = q[2]
            if (rev + f) % 2 == 1:
                dq.append(c)
            else:
                dq.appendleft(c)
    ans = []
    if rev:
        while dq:
            ans.append(dq.popleft())
    else:
        while dq:
            ans.append(dq.pop())
    print(("".join(map(str, ans))))


main()

-    S = deque(eval(input())) +    S = eval(input()) +    from collections import deque + +    dq = deque() +    for c in S: +        dq.appendleft(c) +    rev = 0 -    dir = 0  # 0で手前につける -        q = list(input().split()) +        q = input().split() -            dir += 1 -            dir %= 2 +            rev = (rev + 1) % 2 -            dir2 = dir -            if q[1] == "2": -                dir2 += 1 -                dir2 %= 2 -            if dir2 == 0: -                S.appendleft(q[2]) +            f = int(q[1]) +            c = q[2] +            if (rev + f) % 2 == 1: +                dq.append(c) -                S.append(q[2]) -    ans = list(S) -    if dir == 1: -        ans = ans[::-1] +                dq.appendleft(c) +    ans = [] +    if rev: +        while dq: +            ans.append(dq.popleft()) +    else: +        while dq: +            ans.append(dq.pop())