s = eval(input())

q = int(eval(input()))

li=[list(map(str,input().split())) for _ in range(q)]



moji = "0"

frag = True



for i in range(q):

    que = li[i]

    if que[0] == "1":

        if frag:

            frag = False

        else:

            frag = True

    else:

        f = que[1]

        c = que[2]

        if frag:

            if f == "1":

                moji = c+moji

            else:

                moji = moji+c

        else:

            if f == "1":

                moji = moji+c

            else:

                moji = c+moji





if frag:

    print((moji.replace("0",s)))

else:

    moji = moji[::-1]

    print((moji.replace("0",s[::-1])))
from collections import deque

s = deque(eval(input()))

q = int(eval(input()))

li = [list(map(str, input().split())) for _ in range(q)]



frag = True



for i in range(q):

    que = li[i]

    if que[0] == "1":

        if frag:

            frag = False

        else:

            frag = True

    else:

        f = que[1]

        c = que[2]

        if frag:

            if f == "1":

                s.appendleft(c)

            else:

                s.append(c)

        else:

            if f == "1":

                s.append(c)

            else:

                s.appendleft(c)



if frag:

    print(("".join(s)))

else:

    s.reverse()

    print(("".join(s)))
s = eval(input())
q = int(eval(input()))
li = [list(map(str, input().split())) for _ in range(q)]
moji = "0"
frag = True
for i in range(q):
    que = li[i]
    if que[0] == "1":
        if frag:
            frag = False
        else:
            frag = True
    else:
        f = que[1]
        c = que[2]
        if frag:
            if f == "1":
                moji = c + moji
            else:
                moji = moji + c
        else:
            if f == "1":
                moji = moji + c
            else:
                moji = c + moji
if frag:
    print((moji.replace("0", s)))
else:
    moji = moji[::-1]
    print((moji.replace("0", s[::-1])))

from collections import deque

s = deque(eval(input()))
q = int(eval(input()))
li = [list(map(str, input().split())) for _ in range(q)]
frag = True
for i in range(q):
    que = li[i]
    if que[0] == "1":
        if frag:
            frag = False
        else:
            frag = True
    else:
        f = que[1]
        c = que[2]
        if frag:
            if f == "1":
                s.appendleft(c)
            else:
                s.append(c)
        else:
            if f == "1":
                s.append(c)
            else:
                s.appendleft(c)
if frag:
    print(("".join(s)))
else:
    s.reverse()
    print(("".join(s)))

-s = eval(input()) +from collections import deque + +s = deque(eval(input())) -moji = "0" -                moji = c + moji +                s.appendleft(c) -                moji = moji + c +                s.append(c) -                moji = moji + c +                s.append(c) -                moji = c + moji +                s.appendleft(c) -    print((moji.replace("0", s))) +    print(("".join(s))) -    moji = moji[::-1] -    print((moji.replace("0", s[::-1]))) +    s.reverse() +    print(("".join(s)))