if __name__ == '__main__':



	s = eval(input())

	n = int(eval(input()))



	rvcnt = 0



	tmp = "S"

	tmp_before = ""

	tmp_after = ""

	

	for _ in range(n):

		q = eval(input())

		if len(q) == 1:

			rvcnt += 1

		else:

			i,f,c = list(map(str,q.split()))

			if f == "1":#先頭に追加

				if rvcnt % 2 == 0:

					#先頭に追加

					tmp_before = c + tmp_before

				else:

					#末尾に追加

					tmp_after = tmp_after + c

			else:#末尾に追加

				if rvcnt % 2 == 0:

					#末尾に追加

					tmp_after = tmp_after + c

				else:

					#先頭に追加

					tmp_before = c + tmp_before





	#仮想を元に戻す

	tmp1 = tmp.replace("S",s)

	#連結

	tmp2 = tmp_before + tmp1 + tmp_after



	#最後に反転するかを決定

	if rvcnt % 2 == 1:

		print((tmp2[::-1]))

	else:

		print(tmp2)

from collections import deque

if __name__ == '__main__':



    s = eval(input())

    n = int(eval(input()))



    rvflg = False



    d_st = deque()

    d_ed = deque()



    for _ in range(n):

        q = eval(input())

        if len(q) == 1:

            if rvflg:

                rvflg = False

            else:

                rvflg = True

        else:

            i,f,c = list(map(str,q.split()))

            if f == "1":#先頭に追加

                if rvflg:

                    #末尾に追加

                    d_ed.append(c)

                else:

                    #先頭に追加

                    d_st.appendleft(c)

            else:#末尾に追加

                if rvflg:

                    #先頭に追加

                    d_st.appendleft(c)

                else:

                    #末尾に追加

                    d_ed.append(c)



    ans = "".join(d_st) + s + "".join(d_ed)

    #最後に反転するかを決定

    if rvflg:

        ans = ans[::-1]

    print(ans)



if __name__ == "__main__":
    s = eval(input())
    n = int(eval(input()))
    rvcnt = 0
    tmp = "S"
    tmp_before = ""
    tmp_after = ""
    for _ in range(n):
        q = eval(input())
        if len(q) == 1:
            rvcnt += 1
        else:
            i, f, c = list(map(str, q.split()))
            if f == "1":  # 先頭に追加
                if rvcnt % 2 == 0:
                    # 先頭に追加
                    tmp_before = c + tmp_before
                else:
                    # 末尾に追加
                    tmp_after = tmp_after + c
            else:  # 末尾に追加
                if rvcnt % 2 == 0:
                    # 末尾に追加
                    tmp_after = tmp_after + c
                else:
                    # 先頭に追加
                    tmp_before = c + tmp_before
    # 仮想を元に戻す
    tmp1 = tmp.replace("S", s)
    # 連結
    tmp2 = tmp_before + tmp1 + tmp_after
    # 最後に反転するかを決定
    if rvcnt % 2 == 1:
        print((tmp2[::-1]))
    else:
        print(tmp2)

from collections import deque

if __name__ == "__main__":
    s = eval(input())
    n = int(eval(input()))
    rvflg = False
    d_st = deque()
    d_ed = deque()
    for _ in range(n):
        q = eval(input())
        if len(q) == 1:
            if rvflg:
                rvflg = False
            else:
                rvflg = True
        else:
            i, f, c = list(map(str, q.split()))
            if f == "1":  # 先頭に追加
                if rvflg:
                    # 末尾に追加
                    d_ed.append(c)
                else:
                    # 先頭に追加
                    d_st.appendleft(c)
            else:  # 末尾に追加
                if rvflg:
                    # 先頭に追加
                    d_st.appendleft(c)
                else:
                    # 末尾に追加
                    d_ed.append(c)
    ans = "".join(d_st) + s + "".join(d_ed)
    # 最後に反転するかを決定
    if rvflg:
        ans = ans[::-1]
    print(ans)

+from collections import deque + -    rvcnt = 0 -    tmp = "S" -    tmp_before = "" -    tmp_after = "" +    rvflg = False +    d_st = deque() +    d_ed = deque() -            rvcnt += 1 +            if rvflg: +                rvflg = False +            else: +                rvflg = True -                if rvcnt % 2 == 0: +                if rvflg: +                    # 末尾に追加 +                    d_ed.append(c) +                else: -                    tmp_before = c + tmp_before +                    d_st.appendleft(c) +            else:  # 末尾に追加 +                if rvflg: +                    # 先頭に追加 +                    d_st.appendleft(c) -                    tmp_after = tmp_after + c -            else:  # 末尾に追加 -                if rvcnt % 2 == 0: -                    # 末尾に追加 -                    tmp_after = tmp_after + c -                else: -                    # 先頭に追加 -                    tmp_before = c + tmp_before -    # 仮想を元に戻す -    tmp1 = tmp.replace("S", s) -    # 連結 -    tmp2 = tmp_before + tmp1 + tmp_after +                    d_ed.append(c) +    ans = "".join(d_st) + s + "".join(d_ed) -    if rvcnt % 2 == 1: -        print((tmp2[::-1])) -    else: -        print(tmp2) +    if rvflg: +        ans = ans[::-1] +    print(ans)