using System;
using System.Collections.Generic;
using System.IO.Pipes;
using System.Linq;
using System.Text;

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        void Omame()
        {
            cin = new Scanner();
            string tmpS = cin.next();
            LinkedList<char> S = new LinkedList<char>(tmpS);
            int Q = cin.nextInt();
            bool flag = true;

            for (int i = 0; i < Q; i++)
            {
                int code = cin.nextInt();
                if (code == 1)
                {
                    flag = !flag;
                }
                else
                {
                    int F = cin.nextInt();
                    char C = cin.next()[0];

                    if (flag)
                    {
                        if (F == 1)
                        {
                            S.AddFirst(C);
                        }
                        else
                        {
                            S.AddLast(C);
                        }
                    }
                    else
                    {
                        if (F == 1)
                        {
                            S.AddLast(C);
                        }
                        else
                        {
                            S.AddFirst(C);
                        }
                    }
                }
            }

            char[] ans = S.ToArray();
            if (!flag)
            {
                for (int i = ans.Length - 1; i >= 0; i--)
                {
                    Console.Write(ans[i]);
                }
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine(new String(ans));
            }
        }

    }
}


Measured memory_bytes: 33452