a = eval(input())

n = int(eval(input()))

rev = False

front = []

back = []

q = [eval(input()) for i in range(n)]

for i in q:

    if i == "1":

        rev = not rev

    else:

        i,f,c = i.split()

        if rev == False:

            if f == "1":

                front.append(c)

            else:

                back.append(c)

        else:

            if f == "1":

                back.append(c)

            else:

                front.append(c)

if rev == False:

    print(("".join(list(reversed(front))+[a]+back)))

else:

    print(("".join(list(reversed(back))+[a[::-1]]+front)))
def solve(string):

    s, q, *qs = string.split("\n")

    pre = []

    post = []

    preapp = lambda x:pre.append(x)

    postapp = lambda x:post.append(x)

    r = False

    for _q in qs[::-1]:

        if _q == "1":

            r = not r

            continue

        _, f, c = _q.split()

        if r and f == "2" or not r and f == "1":

            preapp(c)

        else:

            postapp(c)

    pre, post = "".join(pre), "".join(post[::-1])

    return pre + s[::-1] + post if r else pre + s + post



if __name__ == '__main__':

    import sys

    print((solve(sys.stdin.read().strip())))
a = eval(input())
n = int(eval(input()))
rev = False
front = []
back = []
q = [eval(input()) for i in range(n)]
for i in q:
    if i == "1":
        rev = not rev
    else:
        i, f, c = i.split()
        if rev == False:
            if f == "1":
                front.append(c)
            else:
                back.append(c)
        else:
            if f == "1":
                back.append(c)
            else:
                front.append(c)
if rev == False:
    print(("".join(list(reversed(front)) + [a] + back)))
else:
    print(("".join(list(reversed(back)) + [a[::-1]] + front)))

def solve(string):
    s, q, *qs = string.split("\n")
    pre = []
    post = []
    preapp = lambda x: pre.append(x)
    postapp = lambda x: post.append(x)
    r = False
    for _q in qs[::-1]:
        if _q == "1":
            r = not r
            continue
        _, f, c = _q.split()
        if r and f == "2" or not r and f == "1":
            preapp(c)
        else:
            postapp(c)
    pre, post = "".join(pre), "".join(post[::-1])
    return pre + s[::-1] + post if r else pre + s + post


if __name__ == "__main__":
    import sys

    print((solve(sys.stdin.read().strip())))

-a = eval(input()) -n = int(eval(input())) -rev = False -front = [] -back = [] -q = [eval(input()) for i in range(n)] -for i in q: -    if i == "1": -        rev = not rev -    else: -        i, f, c = i.split() -        if rev == False: -            if f == "1": -                front.append(c) -            else: -                back.append(c) +def solve(string): +    s, q, *qs = string.split("\n") +    pre = [] +    post = [] +    preapp = lambda x: pre.append(x) +    postapp = lambda x: post.append(x) +    r = False +    for _q in qs[::-1]: +        if _q == "1": +            r = not r +            continue +        _, f, c = _q.split() +        if r and f == "2" or not r and f == "1": +            preapp(c) -            if f == "1": -                back.append(c) -            else: -                front.append(c) -if rev == False: -    print(("".join(list(reversed(front)) + [a] + back))) -else: -    print(("".join(list(reversed(back)) + [a[::-1]] + front))) +            postapp(c) +    pre, post = "".join(pre), "".join(post[::-1]) +    return pre + s[::-1] + post if r else pre + s + post + + +if __name__ == "__main__": +    import sys + +    print((solve(sys.stdin.read().strip())))