def main():



    S = eval(input())

    Q = int(eval(input()))



    reverse = False

    head = ''

    tail = ''



    for _ in range(Q):

        query= eval(input())

        if query == '1':

            reverse = not reverse

            head, tail = tail, head

        else:

            _, f, c = query.split()

            if f == '1':

                head = ''.join([head,c])

            else:

                tail = ''.join([tail,c])



    if reverse:

        S = S[::-1]



    print((''.join([head[::-1], S, tail])))



if __name__ == "__main__":

    main()
def main():



    S = eval(input())

    Q = int(eval(input()))



    reverse = False

    head = ''

    tail = ''



    for _ in range(Q):

        query= eval(input())

        if query == '1':

            reverse = not reverse

            head, tail = tail, head

        else:

            _, f, c = query.split()

            if f == '1':

#                head = ''.join([head,c])

                head += c

            else:

#                tail = ''.join([tail,c])

                tail += c



    if reverse:

        S = S[::-1]



    print((''.join([head[::-1], S, tail])))



if __name__ == "__main__":

    main()
def main():
    S = eval(input())
    Q = int(eval(input()))
    reverse = False
    head = ""
    tail = ""
    for _ in range(Q):
        query = eval(input())
        if query == "1":
            reverse = not reverse
            head, tail = tail, head
        else:
            _, f, c = query.split()
            if f == "1":
                head = "".join([head, c])
            else:
                tail = "".join([tail, c])
    if reverse:
        S = S[::-1]
    print(("".join([head[::-1], S, tail])))


if __name__ == "__main__":
    main()

def main():
    S = eval(input())
    Q = int(eval(input()))
    reverse = False
    head = ""
    tail = ""
    for _ in range(Q):
        query = eval(input())
        if query == "1":
            reverse = not reverse
            head, tail = tail, head
        else:
            _, f, c = query.split()
            if f == "1":
                #                head = ''.join([head,c])
                head += c
            else:
                #                tail = ''.join([tail,c])
                tail += c
    if reverse:
        S = S[::-1]
    print(("".join([head[::-1], S, tail])))


if __name__ == "__main__":
    main()

-                head = "".join([head, c]) +                #                head = ''.join([head,c]) +                head += c -                tail = "".join([tail, c]) +                #                tail = ''.join([tail,c]) +                tail += c