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+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]))

    



if __name__ == '__main__':

    main() 

  
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+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]))

    



if __name__ == '__main__':

    main() 

  

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 + 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]))


if __name__ == "__main__":
    main()

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 + 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]))


if __name__ == "__main__":
    main()

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