from collections import deque

s=deque(eval(input()))

q=int(eval(input()))

flag = 2



for i in range(q):

    query=input().split()

    if query[0] == "1":

        flag = 3 - flag

    elif int(query[1]) - flag :

         s.appendleft(query[2])

    else:

        s.append(query[2])



if flag-2:

    s.reverse()



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

from collections import deque

s=deque(eval(input()))

q=int(eval(input()))

flag = True



for i in range(q):

    query=input().split()

    if query[0] == "1":

        flag = not flag

    elif query[1] == "1" and flag or query[1] == "2" and not flag :

         s.appendleft(query[2])

    else:

        s.append(query[2])



if not flag:

    s.reverse()



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

from collections import deque

s = deque(eval(input()))
q = int(eval(input()))
flag = 2
for i in range(q):
    query = input().split()
    if query[0] == "1":
        flag = 3 - flag
    elif int(query[1]) - flag:
        s.appendleft(query[2])
    else:
        s.append(query[2])
if flag - 2:
    s.reverse()
print(("".join(s)))

from collections import deque

s = deque(eval(input()))
q = int(eval(input()))
flag = True
for i in range(q):
    query = input().split()
    if query[0] == "1":
        flag = not flag
    elif query[1] == "1" and flag or query[1] == "2" and not flag:
        s.appendleft(query[2])
    else:
        s.append(query[2])
if not flag:
    s.reverse()
print(("".join(s)))

-flag = 2 +flag = True -        flag = 3 - flag -    elif int(query[1]) - flag: +        flag = not flag +    elif query[1] == "1" and flag or query[1] == "2" and not flag: -if flag - 2: +if not flag: