from collections import deque

a = list(eval(input()))

Q = int(eval(input()))

d = deque(a)

ans = 0

for i in range(Q):

  b = list(input().split())

  if len(b) == 1:

    ans += 1

  elif b[1] == "1" and ans % 2 == 0:

    d.appendleft(b[2])

  elif b[1] == "1" and ans % 2 == 1:

    d.append(b[2])

  elif b[1] == "2" and ans % 2 == 0:

    d.append(b[2])

  elif b[1] == "2" and ans % 2 == 1:

    d.appendleft(b[2])

if ans % 2 == 1:

  d.reverse()

print(("".join(d)))
from collections import deque

S = deque(list(eval(input())))

Q = int(eval(input()))

flag = 1

for i in range(Q):

    a = list(input().split())

    if a[0] == '1':

        if flag == 0:

            flag = 1

        else:

            flag = 0

    else:

        if a[1] == '1':

            if flag == 1:

                S.appendleft(a[2])

            else:

                S.append(a[2])

        else:

            if flag == 1:

                S.append(a[2])

            else:

                S.appendleft(a[2])

if flag == 1:

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

else:

    S.reverse()

    print((''.join(S)))  
from collections import deque

a = list(eval(input()))
Q = int(eval(input()))
d = deque(a)
ans = 0
for i in range(Q):
    b = list(input().split())
    if len(b) == 1:
        ans += 1
    elif b[1] == "1" and ans % 2 == 0:
        d.appendleft(b[2])
    elif b[1] == "1" and ans % 2 == 1:
        d.append(b[2])
    elif b[1] == "2" and ans % 2 == 0:
        d.append(b[2])
    elif b[1] == "2" and ans % 2 == 1:
        d.appendleft(b[2])
if ans % 2 == 1:
    d.reverse()
print(("".join(d)))

from collections import deque

S = deque(list(eval(input())))
Q = int(eval(input()))
flag = 1
for i in range(Q):
    a = list(input().split())
    if a[0] == "1":
        if flag == 0:
            flag = 1
        else:
            flag = 0
    else:
        if a[1] == "1":
            if flag == 1:
                S.appendleft(a[2])
            else:
                S.append(a[2])
        else:
            if flag == 1:
                S.append(a[2])
            else:
                S.appendleft(a[2])
if flag == 1:
    print(("".join(S)))
else:
    S.reverse()
    print(("".join(S)))

-a = list(eval(input())) +S = deque(list(eval(input()))) -d = deque(a) -ans = 0 +flag = 1 -    b = list(input().split()) -    if len(b) == 1: -        ans += 1 -    elif b[1] == "1" and ans % 2 == 0: -        d.appendleft(b[2]) -    elif b[1] == "1" and ans % 2 == 1: -        d.append(b[2]) -    elif b[1] == "2" and ans % 2 == 0: -        d.append(b[2]) -    elif b[1] == "2" and ans % 2 == 1: -        d.appendleft(b[2]) -if ans % 2 == 1: -    d.reverse() -print(("".join(d))) +    a = list(input().split()) +    if a[0] == "1": +        if flag == 0: +            flag = 1 +        else: +            flag = 0 +    else: +        if a[1] == "1": +            if flag == 1: +                S.appendleft(a[2]) +            else: +                S.append(a[2]) +        else: +            if flag == 1: +                S.append(a[2]) +            else: +                S.appendleft(a[2]) +if flag == 1: +    print(("".join(S))) +else: +    S.reverse() +    print(("".join(S)))