moji=eval(input())

cycle=int(eval(input()))

flont_or_back=0

flont=""

back=""

for i in range(cycle):

    line=eval(input())

    if line[0]=="1":

        flont_or_back+=1

    else:

        fi=line[2]

        ci=line[4]

        if flont_or_back%2==0:

            if fi=="1":

                flont=ci+flont

            else:

                back+=ci

        else:

            if fi=="1":

                back+=ci

            else:

                flont=ci+flont

moji=flont+moji+back

if flont_or_back%2==0:

    print(moji)

else:

    print((moji[::-1]))
import sys

input = lambda: sys.stdin.readline().rstrip() 

def main():

    moji=eval(input())

    cycle=int(eval(input()))

    flont_or_back=0

    flont=""

    back=""

    for i in range(cycle):

        line=eval(input())

        if line[0]=="1":

            flont_or_back+=1

        else:

            fi=line[2]

            ci=line[4]

            if flont_or_back%2==0:

                if fi=="1":

                    flont+=ci

                else:

                    back+=ci

            else:

                if fi=="1":

                    back+=ci

                else:

                    flont+=ci

    flont=flont[::-1]

    moji=flont+moji+back

    if flont_or_back%2==0:

        print(moji)

    else:

        print((moji[::-1]))

    



if __name__ == '__main__':

    main() 

  

moji = eval(input())
cycle = int(eval(input()))
flont_or_back = 0
flont = ""
back = ""
for i in range(cycle):
    line = eval(input())
    if line[0] == "1":
        flont_or_back += 1
    else:
        fi = line[2]
        ci = line[4]
        if flont_or_back % 2 == 0:
            if fi == "1":
                flont = ci + flont
            else:
                back += ci
        else:
            if fi == "1":
                back += ci
            else:
                flont = ci + flont
moji = flont + moji + back
if flont_or_back % 2 == 0:
    print(moji)
else:
    print((moji[::-1]))

import sys

input = lambda: sys.stdin.readline().rstrip()


def main():
    moji = eval(input())
    cycle = int(eval(input()))
    flont_or_back = 0
    flont = ""
    back = ""
    for i in range(cycle):
        line = eval(input())
        if line[0] == "1":
            flont_or_back += 1
        else:
            fi = line[2]
            ci = line[4]
            if flont_or_back % 2 == 0:
                if fi == "1":
                    flont += ci
                else:
                    back += ci
            else:
                if fi == "1":
                    back += ci
                else:
                    flont += ci
    flont = flont[::-1]
    moji = flont + moji + back
    if flont_or_back % 2 == 0:
        print(moji)
    else:
        print((moji[::-1]))


if __name__ == "__main__":
    main()

-moji = eval(input()) -cycle = int(eval(input())) -flont_or_back = 0 -flont = "" -back = "" -for i in range(cycle): -    line = eval(input()) -    if line[0] == "1": -        flont_or_back += 1 +import sys + +input = lambda: sys.stdin.readline().rstrip() + + +def main(): +    moji = eval(input()) +    cycle = int(eval(input())) +    flont_or_back = 0 +    flont = "" +    back = "" +    for i in range(cycle): +        line = eval(input()) +        if line[0] == "1": +            flont_or_back += 1 +        else: +            fi = line[2] +            ci = line[4] +            if flont_or_back % 2 == 0: +                if fi == "1": +                    flont += ci +                else: +                    back += ci +            else: +                if fi == "1": +                    back += ci +                else: +                    flont += ci +    flont = flont[::-1] +    moji = flont + moji + back +    if flont_or_back % 2 == 0: +        print(moji) -        fi = line[2] -        ci = line[4] -        if flont_or_back % 2 == 0: -            if fi == "1": -                flont = ci + flont -            else: -                back += ci -        else: -            if fi == "1": -                back += ci -            else: -                flont = ci + flont -moji = flont + moji + back -if flont_or_back % 2 == 0: -    print(moji) -else: -    print((moji[::-1])) +        print((moji[::-1])) + + +if __name__ == "__main__": +    main()