#python3

def main():

    s = eval(input())

    addfront = ''

    addback = ''

    q = int(eval(input()))

    direction = 0

    for i in range(q):

        t = eval(input())

        if t[0] == '1':

            direction += 1

            continue

        if t[0] == '2':

            if direction % 2 == 0:

                if t[2] == '1':

                    addfront = t[4] + addfront 

                if t[2] == '2':

                    addback = addback + t[4]

            else:

                if t[2] == '1':

                    addback = addback + t[4]

                if t[2] == '2':

                    addfront = t[4] + addfront

    ans = addfront + s + addback

    if direction%2 == 0:

        print(ans)

    else:

        ans = ''.join(reversed(ans))

        print(ans)

main()

import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



from collections import deque 

def main():

    s = deque(readline().rstrip().decode())

    q = int(readline())

    dir = 1

    for _ in range(q):

        txt = readline().rstrip().decode()

        if txt[0] == '1':

            dir ^= 1

        elif txt[0] == '2':

            f = txt[2]

            c = txt[4]

            if ((dir==1) and (f=='1')) or ((dir==0) and (f=='2')):

                s.appendleft(c)

            else:

                s.append(c)

    if dir!=1:

        print((''.join(reversed(s))))

    else:

        print((''.join(s)))

if __name__ == '__main__':

    main()

# python3
def main():
    s = eval(input())
    addfront = ""
    addback = ""
    q = int(eval(input()))
    direction = 0
    for i in range(q):
        t = eval(input())
        if t[0] == "1":
            direction += 1
            continue
        if t[0] == "2":
            if direction % 2 == 0:
                if t[2] == "1":
                    addfront = t[4] + addfront
                if t[2] == "2":
                    addback = addback + t[4]
            else:
                if t[2] == "1":
                    addback = addback + t[4]
                if t[2] == "2":
                    addfront = t[4] + addfront
    ans = addfront + s + addback
    if direction % 2 == 0:
        print(ans)
    else:
        ans = "".join(reversed(ans))
        print(ans)


main()

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque


def main():
    s = deque(readline().rstrip().decode())
    q = int(readline())
    dir = 1
    for _ in range(q):
        txt = readline().rstrip().decode()
        if txt[0] == "1":
            dir ^= 1
        elif txt[0] == "2":
            f = txt[2]
            c = txt[4]
            if ((dir == 1) and (f == "1")) or ((dir == 0) and (f == "2")):
                s.appendleft(c)
            else:
                s.append(c)
    if dir != 1:
        print(("".join(reversed(s))))
    else:
        print(("".join(s)))


if __name__ == "__main__":
    main()

-# python3 -def main(): -    s = eval(input()) -    addfront = "" -    addback = "" -    q = int(eval(input())) -    direction = 0 -    for i in range(q): -        t = eval(input()) -        if t[0] == "1": -            direction += 1 -            continue -        if t[0] == "2": -            if direction % 2 == 0: -                if t[2] == "1": -                    addfront = t[4] + addfront -                if t[2] == "2": -                    addback = addback + t[4] -            else: -                if t[2] == "1": -                    addback = addback + t[4] -                if t[2] == "2": -                    addfront = t[4] + addfront -    ans = addfront + s + addback -    if direction % 2 == 0: -        print(ans) -    else: -        ans = "".join(reversed(ans)) -        print(ans) +import sys + +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +from collections import deque -main() +def main(): +    s = deque(readline().rstrip().decode()) +    q = int(readline()) +    dir = 1 +    for _ in range(q): +        txt = readline().rstrip().decode() +        if txt[0] == "1": +            dir ^= 1 +        elif txt[0] == "2": +            f = txt[2] +            c = txt[4] +            if ((dir == 1) and (f == "1")) or ((dir == 0) and (f == "2")): +                s.appendleft(c) +            else: +                s.append(c) +    if dir != 1: +        print(("".join(reversed(s)))) +    else: +        print(("".join(s))) + + +if __name__ == "__main__": +    main()