def main():

    from collections import deque

    s = deque(eval(input()))

    q = int(eval(input()))



    flag = 0

    query = []



    for _ in range(q):

        temp = input().split()

        if len(temp) == 1:

            flag += 1

        else:

            query.append(temp + [flag%2])



    for q in query:

        if q[-1] == 0:

            if q[1] == "1":

                s.appendleft(q[2])

            else:

                s.append(q[2])

        else:

            if q[1] == "1":

                s.append(q[2])

            else:

                s.appendleft(q[2])



    if flag % 2 == 1:

        print(("".join(list(s)[::-1])))

    else:

        print(("".join(s)))



main()

from collections import deque



s = deque(eval(input()))

q = int(eval(input()))



flag = True

for _ in range(q):

    temp = input().split()

    if len(temp) == 1:

        flag = not flag

    else:

        if flag:

            if temp[1] == "1":

                s.appendleft(temp[2])

            else:

                s.append(temp[2])

        else:

            if temp[1] == "1":

                s.append(temp[2])

            else:

                s.appendleft(temp[2])



if flag:

    print(("".join(s)))

else:

    print(("".join(list(s)[::-1])))
def main():
    from collections import deque

    s = deque(eval(input()))
    q = int(eval(input()))
    flag = 0
    query = []
    for _ in range(q):
        temp = input().split()
        if len(temp) == 1:
            flag += 1
        else:
            query.append(temp + [flag % 2])
    for q in query:
        if q[-1] == 0:
            if q[1] == "1":
                s.appendleft(q[2])
            else:
                s.append(q[2])
        else:
            if q[1] == "1":
                s.append(q[2])
            else:
                s.appendleft(q[2])
    if flag % 2 == 1:
        print(("".join(list(s)[::-1])))
    else:
        print(("".join(s)))


main()

from collections import deque

s = deque(eval(input()))
q = int(eval(input()))
flag = True
for _ in range(q):
    temp = input().split()
    if len(temp) == 1:
        flag = not flag
    else:
        if flag:
            if temp[1] == "1":
                s.appendleft(temp[2])
            else:
                s.append(temp[2])
        else:
            if temp[1] == "1":
                s.append(temp[2])
            else:
                s.appendleft(temp[2])
if flag:
    print(("".join(s)))
else:
    print(("".join(list(s)[::-1])))

-def main(): -    from collections import deque +from collections import deque -    s = deque(eval(input())) -    q = int(eval(input())) -    flag = 0 -    query = [] -    for _ in range(q): -        temp = input().split() -        if len(temp) == 1: -            flag += 1 +s = deque(eval(input())) +q = int(eval(input())) +flag = True +for _ in range(q): +    temp = input().split() +    if len(temp) == 1: +        flag = not flag +    else: +        if flag: +            if temp[1] == "1": +                s.appendleft(temp[2]) +            else: +                s.append(temp[2]) -            query.append(temp + [flag % 2]) -    for q in query: -        if q[-1] == 0: -            if q[1] == "1": -                s.appendleft(q[2]) +            if temp[1] == "1": +                s.append(temp[2]) -                s.append(q[2]) -        else: -            if q[1] == "1": -                s.append(q[2]) -            else: -                s.appendleft(q[2]) -    if flag % 2 == 1: -        print(("".join(list(s)[::-1]))) -    else: -        print(("".join(s))) - - -main() +                s.appendleft(temp[2]) +if flag: +    print(("".join(s))) +else: +    print(("".join(list(s)[::-1])))