import sys, math

sys.setrecursionlimit(10**5 + 10)



def input():

    return sys.stdin.readline()[:-1]



def main():

    S = eval(input())

    Q = int(eval(input()))

    f = 1

    m = ""

    u = ""

    for k in range(Q):

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

        if q[0] == "1":

            f *= -1

        else:

            if f == 1:

                if q[1] == "1":

                    m = q[2] + m

                else:

                    u = u + q[2]

            else:

                if q[1] == "1":

                    u = u + q[2]

                else:

                    m = q[2] + m

    if f == 1:

        print((m+S+u))

    else:

        print((u[::-1]+S[::-1]+m[::-1]))



if __name__ == '__main__':

    main()

S = eval(input())

T = ""

B = ""

f = 1

for _ in range(int(eval(input()))):

    L = list(input().split())

    if L[0] == "1":

        f *= -1

    else:

        if f == 1:

            if L[1] == "1":

                T += L[2]

            else:

                B += L[2]

        else:

            if L[1] == "1":

                B += L[2]

            else:

                T += L[2]



if f == 1:

    print((T[::-1]+S+B))

else:

    print((B[::-1]+S[::-1]+T))

import sys, math

sys.setrecursionlimit(10**5 + 10)


def input():
    return sys.stdin.readline()[:-1]


def main():
    S = eval(input())
    Q = int(eval(input()))
    f = 1
    m = ""
    u = ""
    for k in range(Q):
        q = list(input().split())
        if q[0] == "1":
            f *= -1
        else:
            if f == 1:
                if q[1] == "1":
                    m = q[2] + m
                else:
                    u = u + q[2]
            else:
                if q[1] == "1":
                    u = u + q[2]
                else:
                    m = q[2] + m
    if f == 1:
        print((m + S + u))
    else:
        print((u[::-1] + S[::-1] + m[::-1]))


if __name__ == "__main__":
    main()

S = eval(input())
T = ""
B = ""
f = 1
for _ in range(int(eval(input()))):
    L = list(input().split())
    if L[0] == "1":
        f *= -1
    else:
        if f == 1:
            if L[1] == "1":
                T += L[2]
            else:
                B += L[2]
        else:
            if L[1] == "1":
                B += L[2]
            else:
                T += L[2]
if f == 1:
    print((T[::-1] + S + B))
else:
    print((B[::-1] + S[::-1] + T))

-import sys, math - -sys.setrecursionlimit(10**5 + 10) - - -def input(): -    return sys.stdin.readline()[:-1] - - -def main(): -    S = eval(input()) -    Q = int(eval(input())) -    f = 1 -    m = "" -    u = "" -    for k in range(Q): -        q = list(input().split()) -        if q[0] == "1": -            f *= -1 +S = eval(input()) +T = "" +B = "" +f = 1 +for _ in range(int(eval(input()))): +    L = list(input().split()) +    if L[0] == "1": +        f *= -1 +    else: +        if f == 1: +            if L[1] == "1": +                T += L[2] +            else: +                B += L[2] -            if f == 1: -                if q[1] == "1": -                    m = q[2] + m -                else: -                    u = u + q[2] +            if L[1] == "1": +                B += L[2] -                if q[1] == "1": -                    u = u + q[2] -                else: -                    m = q[2] + m -    if f == 1: -        print((m + S + u)) -    else: -        print((u[::-1] + S[::-1] + m[::-1])) - - -if __name__ == "__main__": -    main() +                T += L[2] +if f == 1: +    print((T[::-1] + S + B)) +else: +    print((B[::-1] + S[::-1] + T))