s = eval(input())

Q = int(eval(input()))



rev_count = 0

sbf=''

saf=''

for i in range(Q):

    que = eval(input())

    if que[0] == '1':

        rev_count +=1

    elif que[0] == '2':

        if (rev_count + int(que[2]))%2 == 0:

            saf = saf + que[4]

        else:

            sbf = que[4] + sbf



print((sbf+s+saf if rev_count %2 == 0 else (sbf+s+saf)[-1::-1]))

from collections import deque

s = eval(input())

Q = int(eval(input()))



SS =deque(list(s))

rev_count = 0



for i in range(Q):

    que = eval(input())

    if que[0] == '1':

        rev_count +=1

    elif que[0] == '2':

        if (rev_count + int(que[2]))%2 == 0:

            SS.append(que[4])

        else:

            SS.appendleft(que[4])



print(("".join(SS) if rev_count %2 == 0 else ("".join(SS))[-1::-1]))

s = eval(input())
Q = int(eval(input()))
rev_count = 0
sbf = ""
saf = ""
for i in range(Q):
    que = eval(input())
    if que[0] == "1":
        rev_count += 1
    elif que[0] == "2":
        if (rev_count + int(que[2])) % 2 == 0:
            saf = saf + que[4]
        else:
            sbf = que[4] + sbf
print((sbf + s + saf if rev_count % 2 == 0 else (sbf + s + saf)[-1::-1]))

from collections import deque

s = eval(input())
Q = int(eval(input()))
SS = deque(list(s))
rev_count = 0
for i in range(Q):
    que = eval(input())
    if que[0] == "1":
        rev_count += 1
    elif que[0] == "2":
        if (rev_count + int(que[2])) % 2 == 0:
            SS.append(que[4])
        else:
            SS.appendleft(que[4])
print(("".join(SS) if rev_count % 2 == 0 else ("".join(SS))[-1::-1]))

+from collections import deque + +SS = deque(list(s)) -sbf = "" -saf = "" -            saf = saf + que[4] +            SS.append(que[4]) -            sbf = que[4] + sbf -print((sbf + s + saf if rev_count % 2 == 0 else (sbf + s + saf)[-1::-1])) +            SS.appendleft(que[4]) +print(("".join(SS) if rev_count % 2 == 0 else ("".join(SS))[-1::-1]))