using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;

namespace at_coder
{
#if TEST
    [TestClass]
#endif
    public class Test_158_d
    {

#if TEST
        public static void Test_Main()
#else
        public static void Main()
#endif
        {
            string S = ReadString();
            int Q = ReadInt();
            // 前に追加
            StringBuilder s1 = new StringBuilder();
            // 後ろに追加
            StringBuilder s2 = new StringBuilder();

            int revCount = 0;

            for(int i=0;i<Q;i++)
            {
                int t, f;
                char c;
                Read(out t, out f, out c);
                if (t == 1)
                {
                    // 反転
                    revCount++;
                    // 格納領域反転
                    StringBuilder tt = s1;s1 = s2;s2 = tt;
                }
                else
                {
                    if (f == 1)
                    {
                        s1.Append(c);
                    }
                    else
                    {
                        s2.Append(c);
                    }
                }
            }

            if (revCount % 2 == 1)
            {
                S = reverse(S);
            }

            // 結果文字列結合
            StringBuilder ans = new StringBuilder();
            ans.Append(reverse(s1.ToString()));
            ans.Append(S);
            ans.Append(s2.ToString());

            Write(ans.ToString());
        }

        static string reverse(string s)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < s.Length; i++)
            {
                sb.Append(s[s.Length - i - 1]);
            }
            return sb.ToString();
        }

        private static void Read(out int a, out int b, out char c)
        {
            var ar = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            a = int.Parse(ar[0]);
            if (ar.Length > 1)
            {
                b = int.Parse(ar[1]);
                c = ar[2][0];
            }
            else
            {
                b = 0;
                c = '\0';
            }
        }

        private static void Write(string s)
        {
            Console.WriteLine(s);
        }

        private static int[] ReadIntArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int[] ar = new int[ss.Length];
            for (int i = 0; i < ss.Length; i++)
            {
                ar[i] = int.Parse(ss[i]);
            }
            return ar;
        }
        private static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static void ReadInt(out int a, out int b)
        {
            var ar = ReadIntArray();
            a = ar[0];
            b = ar[1];
        }
        
        private static void ReadInt(out int a, out int b, out int c)
        {
            var ar = ReadIntArray();
            a = ar[0];
            b = ar[1];
            c = ar[2];
        }
        private static string ReadString()
        {
            return Console.ReadLine();
        }
        private static string[] ReadStringArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            return ss;
        }
#if !TEST
    }
}
#endif


Measured memory_bytes: 18992