from collections import deque





s = str(input().rstrip())

ans = deque(list(s))



f = True

q = int(eval(input()))

for i in range(q):

    q = list(map(str, input().split()))

    if int(q[0]) == 1:

        if f:

            f = False

        else:

            f = True

    else:

        f_i = int(q[1])

        if f_i == 1:

            if f:

                ans.appendleft(q[2])

            else:

                ans.append(q[2])

        else:

            if f:

                ans.append(q[2])

            else:

                ans.appendleft(q[2])

ans = list(ans)

if f:

    print(("".join(ans)))

else:

    print(("".join(ans[::-1])))

from collections import deque

import sys

input = sys.stdin.readline

s = str(input().rstrip())

ans = deque(list(s))



f = True

q = int(eval(input()))

for i in range(q):

    q = list(map(str, input().split()))

    if int(q[0]) == 1:

        f = not f

    else:

        f_i = int(q[1])

        if (f_i == 1) ^ f:

            ans.append(q[2])

        else:

            ans.appendleft(q[2])

ans = "".join(list(ans))

if not f:

    ans = ans[::-1]

print(ans)

from collections import deque

s = str(input().rstrip())
ans = deque(list(s))
f = True
q = int(eval(input()))
for i in range(q):
    q = list(map(str, input().split()))
    if int(q[0]) == 1:
        if f:
            f = False
        else:
            f = True
    else:
        f_i = int(q[1])
        if f_i == 1:
            if f:
                ans.appendleft(q[2])
            else:
                ans.append(q[2])
        else:
            if f:
                ans.append(q[2])
            else:
                ans.appendleft(q[2])
ans = list(ans)
if f:
    print(("".join(ans)))
else:
    print(("".join(ans[::-1])))

from collections import deque
import sys

input = sys.stdin.readline
s = str(input().rstrip())
ans = deque(list(s))
f = True
q = int(eval(input()))
for i in range(q):
    q = list(map(str, input().split()))
    if int(q[0]) == 1:
        f = not f
    else:
        f_i = int(q[1])
        if (f_i == 1) ^ f:
            ans.append(q[2])
        else:
            ans.appendleft(q[2])
ans = "".join(list(ans))
if not f:
    ans = ans[::-1]
print(ans)

+import sys +input = sys.stdin.readline -        if f: -            f = False -        else: -            f = True +        f = not f -        if f_i == 1: -            if f: -                ans.appendleft(q[2]) -            else: -                ans.append(q[2]) +        if (f_i == 1) ^ f: +            ans.append(q[2]) -            if f: -                ans.append(q[2]) -            else: -                ans.appendleft(q[2]) -ans = list(ans) -if f: -    print(("".join(ans))) -else: -    print(("".join(ans[::-1]))) +            ans.appendleft(q[2]) +ans = "".join(list(ans)) +if not f: +    ans = ans[::-1] +print(ans)