from collections import deque



s = list(eval(input()))

q = int(eval(input()))

s = deque(s)



flg = "order"

for i in range(q):

    t, *f = list(map(str, input().split()))

    if t == "1":

        if flg == "order":

            flg = "reverse"

        else:

            flg = "order"

    else:

        if f[0] == "1":

            if flg == "order":

                s.appendleft(f[1])

            else:

                s.append(f[1])

        else:

            if flg == "order":

                s.append(f[1])

            else:

                s.appendleft(f[1])



if flg == "order":

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

else:

    s.reverse()

    print(("".join(s)))
import sys

from collections import deque



sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

    s = eval(input())

    q = int(eval(input()))

    query = [list(input().split()) for _ in range(q)]



    S = deque([s])

    flg = 1

    for i in range(q):

        if query[i][0] == "1":

            flg ^= 1

        else:

            _, f, c = query[i]

            if f == "1":

                S.appendleft(c) if flg else S.append(c)

            else:

                S.append(c) if flg else S.appendleft(c)



    print(("".join(S) if flg else "".join(S)[::-1]))







if __name__ == '__main__':

    resolve()

from collections import deque

s = list(eval(input()))
q = int(eval(input()))
s = deque(s)
flg = "order"
for i in range(q):
    t, *f = list(map(str, input().split()))
    if t == "1":
        if flg == "order":
            flg = "reverse"
        else:
            flg = "order"
    else:
        if f[0] == "1":
            if flg == "order":
                s.appendleft(f[1])
            else:
                s.append(f[1])
        else:
            if flg == "order":
                s.append(f[1])
            else:
                s.appendleft(f[1])
if flg == "order":
    print(("".join(s)))
else:
    s.reverse()
    print(("".join(s)))

import sys
from collections import deque

sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    s = eval(input())
    q = int(eval(input()))
    query = [list(input().split()) for _ in range(q)]
    S = deque([s])
    flg = 1
    for i in range(q):
        if query[i][0] == "1":
            flg ^= 1
        else:
            _, f, c = query[i]
            if f == "1":
                S.appendleft(c) if flg else S.append(c)
            else:
                S.append(c) if flg else S.appendleft(c)
    print(("".join(S) if flg else "".join(S)[::-1]))


if __name__ == "__main__":
    resolve()

+import sys -s = list(eval(input())) -q = int(eval(input())) -s = deque(s) -flg = "order" -for i in range(q): -    t, *f = list(map(str, input().split())) -    if t == "1": -        if flg == "order": -            flg = "reverse" +sys.setrecursionlimit(10**7) +f_inf = float("inf") +mod = 10**9 + 7 + + +def resolve(): +    s = eval(input()) +    q = int(eval(input())) +    query = [list(input().split()) for _ in range(q)] +    S = deque([s]) +    flg = 1 +    for i in range(q): +        if query[i][0] == "1": +            flg ^= 1 -            flg = "order" -    else: -        if f[0] == "1": -            if flg == "order": -                s.appendleft(f[1]) +            _, f, c = query[i] +            if f == "1": +                S.appendleft(c) if flg else S.append(c) -                s.append(f[1]) -        else: -            if flg == "order": -                s.append(f[1]) -            else: -                s.appendleft(f[1]) -if flg == "order": -    print(("".join(s))) -else: -    s.reverse() -    print(("".join(s))) +                S.append(c) if flg else S.appendleft(c) +    print(("".join(S) if flg else "".join(S)[::-1])) + + +if __name__ == "__main__": +    resolve()