/*********************************************
* 20.05.08 AtCoder Beginner Contest 158. D - String Formation
* 
*
*********************************************/
/*********************************************
문자열 S, 쿼리횟수 Q가 주어질때
1이면 문자열 반전.
2이면 1일때 선두에, 2이면 후미에 문자 추가.
최종문자 출력.

::test input::
S
Q
qry1
...
qryQ

a
4
2 1 p
1
2 2 c
1

*********************************************/

namespace TempName{
    using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.Reflection;
    using System.Text;
    using static System.Console;
    using static IOmacro.CSharpInput; 
    using static IOmacro.CppInput;
    using static IOmacro.CConst;

    public class CRun{
        public readonly char problem_num = 'C';
        
        public void solve_1() {
            
            var output = new string[2];
            output[0] = _string;
            output[1] = "";
            for (int i = 0; i < output[0].Length; i++) {
                output[1] = output[0][i] + output[1];
            }
            int qry_num = 0;
            qry_num = _int;
            short reverse = 0;
            
            for (int i = 0; i < qry_num; i++) {
                var input = _string;
                if (input.Length <= 1) {
                    reverse ^= 1;
                }
                else {
                    string[] qry = input.Split(' ').ToArray();
                    if (qry[1] == "1") {
                        output[reverse] = qry[2] + output[reverse];
                        output[reverse^1] = output[reverse^1] + qry[2];
                    }
                    else if (qry[1] == "2") {
                        output[reverse^1] = qry[2] + output[reverse^1];
                        output[reverse] = output[reverse] + qry[2];
                    }
                }
            }
            
            WriteLine(output[reverse]);
            
        }

        public void solve_2() {
            var output = Enumerable.Range(0, 2).Select(ix => new StringBuilder()).ToList();
            var input = _string;
            output[0].Append(input);
            output[1].Append(string.Join("", input.Reverse()));
            
            int qry_num = _int;
            short rev_chk = 0;
            
            for (int i = 0; i < qry_num; i++) {
                var qry = _string;
                if (qry.Length <= 1) {
                    rev_chk ^= 1;
                }
                else {
                    string[] qry_detail = qry.Split(' ').ToArray();
                    if (qry_detail[1] == "1") {
                        output[rev_chk].Insert(0,qry_detail[2]);
                        output[rev_chk^1].Append(qry_detail[2]);
                    }
                    else if (qry_detail[1] == "2") {
                        output[rev_chk^1].Insert(0, qry_detail[2]);
                        output[rev_chk].Append(qry_detail[2]);
                    }
                }
            }
            
            WriteLine(output[rev_chk]);
        }

        public void solve_3() {
            var output = Enumerable.Range(0,2).Select(ix => new LinkedList<char>()).ToArray();
            var input = _string;
            foreach (var ix in input) output[0].AddLast(ix);
            for (int ix = input.Length -1; ix >= 0; ix--) output[1].AddLast(input[ix]);
            
            int query_num = _int;
            short rev_chk = 0;
            for (int ix = 0; ix < query_num; ix++) {
                var query = _string;
                if (query.Length <= 1) {
                    rev_chk ^= 1;
                }
                else {
                    char[] query_detail = query.ToCharArray();
                    if (query_detail[2] == '1') {
                        output[rev_chk].AddFirst(query_detail[4]);
                        output[rev_chk^1].AddLast(query_detail[4]);
                    }
                    else if (query_detail[2] == '2') {
                        output[rev_chk].AddLast(query_detail[4]);
                        output[rev_chk^1].AddFirst(query_detail[4]);
                    }
                }
            }
            
            WriteLine(string.Join("", output[rev_chk]));
        }
    }
    
    class Program { 
        static void Main() { 
            var run = new CRun();
            if (run.problem_num == 'A') run.solve_1(); 
            if (run.problem_num == 'B') run.solve_2(); 
            if (run.problem_num == 'C') run.solve_3();
        } 
    }
}

namespace IOmacro {
    //20.05.08. 수정
    
    using System; 
    using System.Linq; 
    using System.IO;
    using System.Collections.Generic;
    
    public class CSharpInput {
        public static StreamWriter _writer = new StreamWriter(Console.OpenStandardOutput());
        public const char separator = ' ';
        public static string _string{get{return Console.ReadLine();}}
        public static string[] _stringa{get{return (Console.ReadLine().Split(separator));}}
        public static int _int{get{return int.Parse(Console.ReadLine());}}
        public static int[] _inta{get{return Console.ReadLine().Split(separator).Select(int.Parse).ToArray();}}
        public static long _long{get{return long.Parse(Console.ReadLine());}}
        public static long[] _longa{get{return Console.ReadLine().Split(separator).Select(long.Parse).ToArray();}}    
        public static double _double{get{return double.Parse(Console.ReadLine());}}
        public static double[] _doublea{get{return Console.ReadLine().Split(separator).Select(double.Parse).ToArray();}}    
    }
    
    public class CConst {
        public static readonly int MINI = int.MaxValue;
        public static readonly long INF = Int64.MaxValue;
    }
    
    public class CppInput {
        public static CppInput cin => new CppInput();
        public const char separator = ' ';
        private static readonly Queue<string> _input = new Queue<string>();
        private CppInput(){}
        public static implicit operator string(CppInput _) {
            if (_input.Count == 0) Console.ReadLine().Split(separator).foreachExtension(x => _input.Enqueue(x));
            return _input.Dequeue();
        }
        public static implicit operator int(CppInput _){
            if (_input.Count == 0) Console.ReadLine().Split(separator).foreachExtension(x => _input.Enqueue(x));
            return int.Parse(_input.Dequeue());
        }
        public static implicit operator long(CppInput _){
            if (_input.Count == 0) Console.ReadLine().Split(separator).foreachExtension(x => _input.Enqueue(x));
            return long.Parse(_input.Dequeue());
        }
        public static implicit operator double(CppInput _){
            if (_input.Count == 0) Console.ReadLine().Split(separator).foreachExtension(x => _input.Enqueue(x));
            return double.Parse(_input.Dequeue());
        }
    }
    
    public static class EnumerableExtension {
        public delegate void Function<in T>(T val);
        public static void foreachExtension<T>(this IEnumerable<T> enumerable, Function<T> function) {
            foreach (var x in enumerable) function(x);
        }
    }
}




Measured memory_bytes: 48684