from collections import deque

def main():

    S = deque([s for s in eval(input())])

    Q = int(eval(input()))

    order = True

    for i in range(Q):

        query = input().split()

        t = int(query[0])

        if t == 1:

            order = not order

        else:

            f = int(query[1])

            c = query[2]

            left = True

            if f == 1:

                if order:

                    left = True

                else:

                    left = False

            else:

                if order:

                    left = False

                else:

                    left = True

            if left:

                S.appendleft(c)

            else:

                S.append(c)

    if not order:

        S.reverse()

    print((''.join(S)))



if __name__ == '__main__':

    main()

from collections import deque

from sys import stdin



def main():

    S = deque([s for s in eval(input())])

    Q = int(eval(input()))

    order = True

    for i in range(Q):

        query = stdin.readline().split()

        t = int(query[0])

        if t == 1:

            order = not order

        else:

            f = int(query[1])

            c = query[2]

            if not order:

                f = 3  - f # 2, 1 -> 1, 2

            left = True

            if f == 1:

                S.appendleft(c)

            else:

                S.append(c)

    if not order:

        S.reverse()

    print((''.join(S)))



if __name__ == '__main__':

    main()

from collections import deque


def main():
    S = deque([s for s in eval(input())])
    Q = int(eval(input()))
    order = True
    for i in range(Q):
        query = input().split()
        t = int(query[0])
        if t == 1:
            order = not order
        else:
            f = int(query[1])
            c = query[2]
            left = True
            if f == 1:
                if order:
                    left = True
                else:
                    left = False
            else:
                if order:
                    left = False
                else:
                    left = True
            if left:
                S.appendleft(c)
            else:
                S.append(c)
    if not order:
        S.reverse()
    print(("".join(S)))


if __name__ == "__main__":
    main()

from collections import deque
from sys import stdin


def main():
    S = deque([s for s in eval(input())])
    Q = int(eval(input()))
    order = True
    for i in range(Q):
        query = stdin.readline().split()
        t = int(query[0])
        if t == 1:
            order = not order
        else:
            f = int(query[1])
            c = query[2]
            if not order:
                f = 3 - f  # 2, 1 -> 1, 2
            left = True
            if f == 1:
                S.appendleft(c)
            else:
                S.append(c)
    if not order:
        S.reverse()
    print(("".join(S)))


if __name__ == "__main__":
    main()

+from sys import stdin -        query = input().split() +        query = stdin.readline().split() +            if not order: +                f = 3 - f  # 2, 1 -> 1, 2 -                if order: -                    left = True -                else: -                    left = False -            else: -                if order: -                    left = False -                else: -                    left = True -            if left: