S = eval(input())

Q = int(eval(input()))

Query = [input().split() for _ in range(Q)]



rev = False

S1 = ''

S2 = ''



for TFC in Query:

    if TFC[0] == '1':

        rev = not rev

    else:

        if TFC[1] == '1':

            if rev:

                S2 += TFC[2]

            else:

                S1 = TFC[2] + S1

        else:

            if rev:

                S1 = TFC[2] + S1

            else:

                S2 += TFC[2]



if rev:

    print((S2[::-1] + S[::-1] + S1[::-1]))

else:

    print((S1 + S + S2))
from collections import deque



S = eval(input())

Q = int(eval(input()))

Query = [input().split() for _ in range(Q)]



S = deque(S)

rev = False



for TFC in Query:

    if TFC[0] == '1':

        rev = not rev

    else:

        if TFC[1] == '1':

            if rev:

                S.append(TFC[2])

            else:

                S.appendleft(TFC[2])

        else:

            if rev:

                S.appendleft(TFC[2])

            else:

                S.append(TFC[2])

if rev:

    S.reverse()

print((''.join(S)))
S = eval(input())
Q = int(eval(input()))
Query = [input().split() for _ in range(Q)]
rev = False
S1 = ""
S2 = ""
for TFC in Query:
    if TFC[0] == "1":
        rev = not rev
    else:
        if TFC[1] == "1":
            if rev:
                S2 += TFC[2]
            else:
                S1 = TFC[2] + S1
        else:
            if rev:
                S1 = TFC[2] + S1
            else:
                S2 += TFC[2]
if rev:
    print((S2[::-1] + S[::-1] + S1[::-1]))
else:
    print((S1 + S + S2))

from collections import deque

S = eval(input())
Q = int(eval(input()))
Query = [input().split() for _ in range(Q)]
S = deque(S)
rev = False
for TFC in Query:
    if TFC[0] == "1":
        rev = not rev
    else:
        if TFC[1] == "1":
            if rev:
                S.append(TFC[2])
            else:
                S.appendleft(TFC[2])
        else:
            if rev:
                S.appendleft(TFC[2])
            else:
                S.append(TFC[2])
if rev:
    S.reverse()
print(("".join(S)))

+from collections import deque + +S = deque(S) -S1 = "" -S2 = "" -                S2 += TFC[2] +                S.append(TFC[2]) -                S1 = TFC[2] + S1 +                S.appendleft(TFC[2]) -                S1 = TFC[2] + S1 +                S.appendleft(TFC[2]) -                S2 += TFC[2] +                S.append(TFC[2]) -    print((S2[::-1] + S[::-1] + S1[::-1])) -else: -    print((S1 + S + S2)) +    S.reverse() +print(("".join(S)))