from collections import deque



s = deque(eval(input()))

n = int(eval(input()))

l = [input().split(" ") for _ in range(n)]



x = 0

for i in range(n):

    if l[i][0]=='1':

        if x == 0:

            x = 1

        else:

            x = 0

    elif l[i][0]=='2':

        if x == 0:

            if l[i][1]=='1':

                s.appendleft(l[i][2])

            else:

                s.append(l[i][2])

        else:

            if l[i][1]=='1':

                s.append(l[i][2])

            else:

                s.appendleft(l[i][2])



if x == 0:

    print((''.join(s)))

else:

    print((''.join(reversed(s))))
from collections import deque



s = deque(eval(input()))

n = int(eval(input()))



#x.append(y)

#x.appendleft(y)



memo = 0

for i in range(n):

    q = list(input().split())

    if q[0] == '1':

        if  memo == 0: memo = 1

        else: memo = 0

    else:

        if memo == 0:

            if q[1] == '1': s.appendleft(q[2])

            else: s.append(q[2])

        else:

            if q[1] == '1': s.append(q[2])

            else: s.appendleft(q[2])



if memo == 0: print((''.join(s)))

else: print((''.join(list(s)[::-1])))

from collections import deque

s = deque(eval(input()))
n = int(eval(input()))
l = [input().split(" ") for _ in range(n)]
x = 0
for i in range(n):
    if l[i][0] == "1":
        if x == 0:
            x = 1
        else:
            x = 0
    elif l[i][0] == "2":
        if x == 0:
            if l[i][1] == "1":
                s.appendleft(l[i][2])
            else:
                s.append(l[i][2])
        else:
            if l[i][1] == "1":
                s.append(l[i][2])
            else:
                s.appendleft(l[i][2])
if x == 0:
    print(("".join(s)))
else:
    print(("".join(reversed(s))))

from collections import deque

s = deque(eval(input()))
n = int(eval(input()))
# x.append(y)
# x.appendleft(y)
memo = 0
for i in range(n):
    q = list(input().split())
    if q[0] == "1":
        if memo == 0:
            memo = 1
        else:
            memo = 0
    else:
        if memo == 0:
            if q[1] == "1":
                s.appendleft(q[2])
            else:
                s.append(q[2])
        else:
            if q[1] == "1":
                s.append(q[2])
            else:
                s.appendleft(q[2])
if memo == 0:
    print(("".join(s)))
else:
    print(("".join(list(s)[::-1])))

-l = [input().split(" ") for _ in range(n)] -x = 0 +# x.append(y) +# x.appendleft(y) +memo = 0 -    if l[i][0] == "1": -        if x == 0: -            x = 1 +    q = list(input().split()) +    if q[0] == "1": +        if memo == 0: +            memo = 1 -            x = 0 -    elif l[i][0] == "2": -        if x == 0: -            if l[i][1] == "1": -                s.appendleft(l[i][2]) +            memo = 0 +    else: +        if memo == 0: +            if q[1] == "1": +                s.appendleft(q[2]) -                s.append(l[i][2]) +                s.append(q[2]) -            if l[i][1] == "1": -                s.append(l[i][2]) +            if q[1] == "1": +                s.append(q[2]) -                s.appendleft(l[i][2]) -if x == 0: +                s.appendleft(q[2]) +if memo == 0: -    print(("".join(reversed(s)))) +    print(("".join(list(s)[::-1])))