import sys

import collections



sys.setrecursionlimit(10 ** 8)



input = sys.stdin.readline





def main():

    S = input().strip()

    Q = int(input())



    rev = 0

    sdeq = collections.deque()

    for s in S:

        sdeq.append(ord(s) - ord('a'))



    for i in range(Q):

        A = [x for x in input().split()]

        if len(A) == 1:

            rev = (rev + 1) % 2

        else:

            f = int(A[1])

            c = A[2]

            if f == 1:

                if rev == 0:

                    sdeq.appendleft(ord(c) - ord('a'))

                else:

                    sdeq.append(ord(c) - ord('a'))

            else:

                if rev == 0:

                    sdeq.append(ord(c) - ord('a'))

                else:

                    sdeq.appendleft(ord(c) - ord('a'))



    if rev == 0:

        for i in list(sdeq):

            print(chr(i + ord('a')), end="")

    else:

        for i in list(sdeq)[::-1]:

            print(chr(i + ord('a')), end="")

    print()







if __name__ == '__main__':

    main()

import sys

import collections



sys.setrecursionlimit(10 ** 8)



input = sys.stdin.readline





def main():

    S = input().strip()

    Q = int(eval(input()))



    rev = 0

    sdeq = collections.deque(list(S))



    for i in range(Q):

        A = [x for x in input().split()]

        if len(A) == 1:

            rev = (rev + 1) % 2

        else:

            f = int(A[1])

            c = A[2]

            if f == 1:

                if rev == 0:

                    sdeq.appendleft(c)

                else:

                    sdeq.append(c)

            else:

                if rev == 0:

                    sdeq.append(c)

                else:

                    sdeq.appendleft(c)



    if rev == 0:

        print(("".join(list(sdeq))))

    else:

        print(("".join(list(sdeq)[::-1])))

    print()







if __name__ == '__main__':

    main()

import sys
import collections

sys.setrecursionlimit(10**8)
input = sys.stdin.readline


def main():
    S = input().strip()
    Q = int(input())
    rev = 0
    sdeq = collections.deque()
    for s in S:
        sdeq.append(ord(s) - ord("a"))
    for i in range(Q):
        A = [x for x in input().split()]
        if len(A) == 1:
            rev = (rev + 1) % 2
        else:
            f = int(A[1])
            c = A[2]
            if f == 1:
                if rev == 0:
                    sdeq.appendleft(ord(c) - ord("a"))
                else:
                    sdeq.append(ord(c) - ord("a"))
            else:
                if rev == 0:
                    sdeq.append(ord(c) - ord("a"))
                else:
                    sdeq.appendleft(ord(c) - ord("a"))
    if rev == 0:
        for i in list(sdeq):
            print(chr(i + ord("a")), end="")
    else:
        for i in list(sdeq)[::-1]:
            print(chr(i + ord("a")), end="")
    print()


if __name__ == "__main__":
    main()

import sys
import collections

sys.setrecursionlimit(10**8)
input = sys.stdin.readline


def main():
    S = input().strip()
    Q = int(eval(input()))
    rev = 0
    sdeq = collections.deque(list(S))
    for i in range(Q):
        A = [x for x in input().split()]
        if len(A) == 1:
            rev = (rev + 1) % 2
        else:
            f = int(A[1])
            c = A[2]
            if f == 1:
                if rev == 0:
                    sdeq.appendleft(c)
                else:
                    sdeq.append(c)
            else:
                if rev == 0:
                    sdeq.append(c)
                else:
                    sdeq.appendleft(c)
    if rev == 0:
        print(("".join(list(sdeq))))
    else:
        print(("".join(list(sdeq)[::-1])))
    print()


if __name__ == "__main__":
    main()

-    Q = int(input()) +    Q = int(eval(input())) -    sdeq = collections.deque() -    for s in S: -        sdeq.append(ord(s) - ord("a")) +    sdeq = collections.deque(list(S)) -                    sdeq.appendleft(ord(c) - ord("a")) +                    sdeq.appendleft(c) -                    sdeq.append(ord(c) - ord("a")) +                    sdeq.append(c) -                    sdeq.append(ord(c) - ord("a")) +                    sdeq.append(c) -                    sdeq.appendleft(ord(c) - ord("a")) +                    sdeq.appendleft(c) -        for i in list(sdeq): -            print(chr(i + ord("a")), end="") +        print(("".join(list(sdeq)))) -        for i in list(sdeq)[::-1]: -            print(chr(i + ord("a")), end="") +        print(("".join(list(sdeq)[::-1])))