### BUGGY CODE ###

#!/usr/bin/env python3
import sys


def solve(S, Q, Qvery):
    fw = True
    ret = list(S)
    # ret.append(S)
    for qvery in Qvery:
        if qvery[0] == 1:
            # fw = not fw
            if fw:
                fw = False
            else:
                fw = True
        else:
            if qvery[1] == 1 and fw or qvery[1] == 2 and not fw:  # 先頭に追加
                ret.insert(0, qvery[2])
                # S = qvery[2] + S
            else:  # 末尾に追加
                ret.append(qvery[2])
                # S = S + qvery[2]

    if fw:
        print(''.join(ret))
    else:
        rev_ret = ret[::-1]
        print(''.join(rev_ret))


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    Qvery = []
    for i in range(Q):
        T = int(next(tokens))
        if T == 1:
            Qvery.append([1])
        elif T == 2:
            Qvery.append([2, int(next(tokens)), str(next(tokens))])
    solve(S, Q, Qvery)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(S, Q, Qvery):
    pool = []
    fw = True
    for qvery in reversed(Qvery):
        if qvery[0] == 1:
            if fw:
                fw = False
            else:
                fw = True
        else:
            if qvery[1] == 1 and fw or qvery[1] == 2 and not fw:  # 先頭に描く
                print(qvery[2], end='')
            else:
                pool.append(qvery[2])

    if fw:
        print(S, end='')
    else:
        rev_S = S[::-1]
        print(rev_S, end='')
    for p in reversed(pool):
        print(p, end='')
    print()

    # fw = True
    # ret = list(S)
    # # ret.append(S)
    # for qvery in Qvery:
    #     if qvery[0] == 1:
    #         # fw = not fw
    #         if fw:
    #             fw = False
    #         else:
    #             fw = True
    #     else:
    #         if qvery[1] == 1 and fw or qvery[1] == 2 and not fw:  # 先頭に追加
    #             ret.insert(0, qvery[2])
    #             # S = qvery[2] + S
    #         else:  # 末尾に追加
    #             ret.append(qvery[2])
    #             # S = S + qvery[2]

    # if fw:
    #     print(''.join(ret))
    # else:
    #     rev_ret = ret[::-1]
    #     print(''.join(rev_ret))


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    Qvery = []
    for i in range(Q):
        T = int(next(tokens))
        if T == 1:
            Qvery.append([1])
        elif T == 2:
            Qvery.append([2, int(next(tokens)), str(next(tokens))])
    solve(S, Q, Qvery)

if __name__ == '__main__':
    main()