using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Solve.Answer();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var s = ReadLine();
            var q = IO.ReadInt;
            var sb = new StringBuilder(s);
            var sb2 = new StringBuilder();
            int reversecnt = 0;
            for (int i = 0; i < q; i++)
            {
                var query = ReadLine().Split();
                if (query[0] == "1")
                {
                    reversecnt++;
                    continue;
                }
                else
                {
                    if (reversecnt % 2 == 0)
                    {
                        if (query[1] == "1")
                        {
                            sb2.Append(query[2]);
                        }
                        else
                        {
                            sb.Append(query[2]);
                        }
                    }
                    else
                    {
                        if (query[1] == "1")
                        {
                            sb.Append(query[2]);
                        }
                        else
                        {
                            sb2.Append(query[2]);
                        }
                    }
                }
            }
            string str1 = sb.ToString();
            string str2 = new string(sb2.ToString().Reverse().ToArray());
            string str = str2 + str1;
            if (reversecnt % 2 == 1) str = new string(str.Reverse().ToArray());
            WriteLine(str);
        }

        public class IO
        {
            #region Input
            public static string ReadString => ReadLine();
            public static int ReadInt => int.Parse(ReadLine());
            public static long ReadLong => long.Parse(ReadLine());
            public static double ReadDouble => double.Parse(ReadLine());

            public static List<string> ReadSplitString => ReadLine().Split().ToList();
            public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList();
            public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList();
            public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList();
            #endregion

            #region Output
            public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
            public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");

            #endregion
        }

        public class Mod
        {
            #region
            private readonly static long M = 1000000007;

            public static long Add(long a, long b) => (a * b) % M;
            public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
            public static long Multi(long a, long b) => (a * b) % M;
            #endregion
        }

        public static long GCD(long x, long y)
        {
            #region
            if (x < y)
            {
                var tmp = x;
                x = y;
                y = tmp;
            }
            while (true)

            {
                if (x % y == 0)
                {
                    return y;
                }
                else
                {
                    var tmp = x;
                    x = y;
                    y = tmp % y;
                }
            }
            #endregion
        }

        public static long Choice2(long n)
        {
            #region
            if (n <= 1)
                return 0;
            if (n == 2)
                return 1;
            else
                return n * (n - 1) / 2;
            #endregion
        }
    }
}

Measured memory_bytes: 23740