# D - String Formation

from collections import deque





def main():

    S = input().rstrip()

    Q = int(eval(input()))

    queue = deque(S)

    is_reversed = 0

    for _ in range(Q):

        query = input().split()

        if query[0] == "1":

            is_reversed ^= 1

            continue

        com, c = query[1], query[2]

        if com == "1":

            if not is_reversed:

                queue.appendleft(c)

            else:

                queue.append(c)

        else:

            if not is_reversed:

                queue.append(c)

            else:

                queue.appendleft(c)

    ans = "".join(queue) if not is_reversed else "".join(reversed(queue))

    print(ans)





if __name__ == "__main__":

    main()

# D - String Formation

import sys

from collections import deque



readline = sys.stdin.readline

readlines = sys.stdin.readlines





def main():

    S = readline().rstrip()

    _ = readline()

    queries = readlines()

    queue = deque(S)

    to_beginning, to_end = queue.appendleft, queue.append

    is_reversed = 0

    for query in queries:

        if query[0] == "1":

            to_beginning, to_end = to_end, to_beginning

            is_reversed ^= 1

            continue

        com, c = query[2], query[4]

        if com == "1":

            to_beginning(c)

        else:

            to_end(c)

    ans = "".join(queue) if not is_reversed else "".join(reversed(queue))

    print(ans)





if __name__ == "__main__":

    main()

# D - String Formation
from collections import deque


def main():
    S = input().rstrip()
    Q = int(eval(input()))
    queue = deque(S)
    is_reversed = 0
    for _ in range(Q):
        query = input().split()
        if query[0] == "1":
            is_reversed ^= 1
            continue
        com, c = query[1], query[2]
        if com == "1":
            if not is_reversed:
                queue.appendleft(c)
            else:
                queue.append(c)
        else:
            if not is_reversed:
                queue.append(c)
            else:
                queue.appendleft(c)
    ans = "".join(queue) if not is_reversed else "".join(reversed(queue))
    print(ans)


if __name__ == "__main__":
    main()

# D - String Formation
import sys
from collections import deque

readline = sys.stdin.readline
readlines = sys.stdin.readlines


def main():
    S = readline().rstrip()
    _ = readline()
    queries = readlines()
    queue = deque(S)
    to_beginning, to_end = queue.appendleft, queue.append
    is_reversed = 0
    for query in queries:
        if query[0] == "1":
            to_beginning, to_end = to_end, to_beginning
            is_reversed ^= 1
            continue
        com, c = query[2], query[4]
        if com == "1":
            to_beginning(c)
        else:
            to_end(c)
    ans = "".join(queue) if not is_reversed else "".join(reversed(queue))
    print(ans)


if __name__ == "__main__":
    main()

+import sys + +readline = sys.stdin.readline +readlines = sys.stdin.readlines -    S = input().rstrip() -    Q = int(eval(input())) +    S = readline().rstrip() +    _ = readline() +    queries = readlines() +    to_beginning, to_end = queue.appendleft, queue.append -    for _ in range(Q): -        query = input().split() +    for query in queries: +            to_beginning, to_end = to_end, to_beginning -        com, c = query[1], query[2] +        com, c = query[2], query[4] -            if not is_reversed: -                queue.appendleft(c) -            else: -                queue.append(c) +            to_beginning(c) -            if not is_reversed: -                queue.append(c) -            else: -                queue.appendleft(c) +            to_end(c)