def main():

    from sys import stdin

    #input = sys.stdin.readline

    #sys.setrecursionlimit(10000000)

    from collections import Counter, deque

    #from collections import defaultdict

    from itertools import combinations, permutations

    #from itertools import accumulate, product

    from bisect import bisect_left,bisect_right

    from math import floor, ceil

    #from operator import itemgetter



    #mod = 1000000007



    S = eval(input())

    Q = int(eval(input()))

    mae = ''

    usiro = ''

    s = True

    for _ in range(Q):

        q = stdin.readline()

        if q[0]=='1':

            s = not s

        else:

            if q[2]=='1' and s:

                mae = q[4] + mae

            elif q[2]=='2' and s:

                usiro = usiro + q[4] 

            elif q[2]=='2' and not s:

                mae = q[4] + mae

            else:

                usiro = usiro + q[4]

    if s:

        print((mae+S+usiro))

    else:

        print((usiro[::-1]+S[::-1]+mae[::-1]))





if __name__ == '__main__':

    main()

#AC出てから！ファイル整理！

#コンテストはatcoder.pyで！

#A:

#B:

#C:

#D:

#DP

#ナップザックの残り

#56と復習



import sys

#input = sys.stdin.readline

sys.setrecursionlimit(10000000)

from collections import Counter, deque

#from collections import defaultdict

from itertools import combinations, permutations

#from itertools import accumulate, product

from bisect import bisect_left,bisect_right

from math import floor, ceil

#from operator import itemgetter



#mod = 1000000007



def main():

    from sys import stdin

    #input = sys.stdin.readline

    sys.setrecursionlimit(10000000)

    from collections import Counter, deque

    #from collections import defaultdict

    from itertools import combinations, permutations

    #from itertools import accumulate, product

    from bisect import bisect_left,bisect_right

    from math import floor, ceil

    #from operator import itemgetter



    #mod = 1000000007



    S = list(stdin.readline().rstrip())

    Q = int(eval(input()))

    mae = []

    usiro =[]

    s = True

    for _ in range(Q):

        q = stdin.readline()

        if q[0]=='1':

            s = not s

        else:

            if q[2]=='1' and s:

                mae.append(q[4])

            elif q[2]=='2' and s:

                usiro.append(q[4])

            elif q[2]=='2' and not s:

                mae.append(q[4])

            else:

                usiro.append(q[4])

    if s:

        print((''.join(mae[::-1]+S+usiro)))

    else:

        print((''.join(usiro[::-1]+S[::-1]+mae)))





if __name__ == '__main__':

    main()

def main():
    from sys import stdin

    # input = sys.stdin.readline
    # sys.setrecursionlimit(10000000)
    from collections import Counter, deque

    # from collections import defaultdict
    from itertools import combinations, permutations

    # from itertools import accumulate, product
    from bisect import bisect_left, bisect_right
    from math import floor, ceil

    # from operator import itemgetter
    # mod = 1000000007
    S = eval(input())
    Q = int(eval(input()))
    mae = ""
    usiro = ""
    s = True
    for _ in range(Q):
        q = stdin.readline()
        if q[0] == "1":
            s = not s
        else:
            if q[2] == "1" and s:
                mae = q[4] + mae
            elif q[2] == "2" and s:
                usiro = usiro + q[4]
            elif q[2] == "2" and not s:
                mae = q[4] + mae
            else:
                usiro = usiro + q[4]
    if s:
        print((mae + S + usiro))
    else:
        print((usiro[::-1] + S[::-1] + mae[::-1]))


if __name__ == "__main__":
    main()

# AC出てから！ファイル整理！
# コンテストはatcoder.pyで！
# A:
# B:
# C:
# D:
# DP
# ナップザックの残り
# 56と復習
import sys

# input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import Counter, deque

# from collections import defaultdict
from itertools import combinations, permutations

# from itertools import accumulate, product
from bisect import bisect_left, bisect_right
from math import floor, ceil

# from operator import itemgetter
# mod = 1000000007
def main():
    from sys import stdin

    # input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque

    # from collections import defaultdict
    from itertools import combinations, permutations

    # from itertools import accumulate, product
    from bisect import bisect_left, bisect_right
    from math import floor, ceil

    # from operator import itemgetter
    # mod = 1000000007
    S = list(stdin.readline().rstrip())
    Q = int(eval(input()))
    mae = []
    usiro = []
    s = True
    for _ in range(Q):
        q = stdin.readline()
        if q[0] == "1":
            s = not s
        else:
            if q[2] == "1" and s:
                mae.append(q[4])
            elif q[2] == "2" and s:
                usiro.append(q[4])
            elif q[2] == "2" and not s:
                mae.append(q[4])
            else:
                usiro.append(q[4])
    if s:
        print(("".join(mae[::-1] + S + usiro)))
    else:
        print(("".join(usiro[::-1] + S[::-1] + mae)))


if __name__ == "__main__":
    main()

+# AC出てから！ファイル整理！ +# コンテストはatcoder.pyで！ +# A: +# B: +# C: +# D: +# DP +# ナップザックの残り +# 56と復習 +import sys + +# input = sys.stdin.readline +sys.setrecursionlimit(10000000) +from collections import Counter, deque + +# from collections import defaultdict +from itertools import combinations, permutations + +# from itertools import accumulate, product +from bisect import bisect_left, bisect_right +from math import floor, ceil + +# from operator import itemgetter +# mod = 1000000007 -    # sys.setrecursionlimit(10000000) +    sys.setrecursionlimit(10000000) -    S = eval(input()) +    S = list(stdin.readline().rstrip()) -    mae = "" -    usiro = "" +    mae = [] +    usiro = [] -                mae = q[4] + mae +                mae.append(q[4]) -                usiro = usiro + q[4] +                usiro.append(q[4]) -                mae = q[4] + mae +                mae.append(q[4]) -                usiro = usiro + q[4] +                usiro.append(q[4]) -        print((mae + S + usiro)) +        print(("".join(mae[::-1] + S + usiro))) -        print((usiro[::-1] + S[::-1] + mae[::-1])) +        print(("".join(usiro[::-1] + S[::-1] + mae)))