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

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Node
    {
        public Node Parent { get; set; }
        public Node Child { get; set; }
        public char Value { get; set; }

        public Node(char val)
        {
            this.Value = val;
        }

        public Node AddParent(char val)
        {
            var node = new Node(val);
            node.Child = this;
            this.Parent = node;
            return node;
        }

        public Node AddChild(char val)
        {
            var node = new Node(val);
            node.Parent = this;
            this.Child = node;
            return node;
        }

        public override string ToString()
        {
            return new string(this.Value, 1);
        }
    }

    class Solver
    {
        public Node TopNode { get; set; }
        public Node LastNode { get; set; }

        public void Solve()
        {
            var S = Console.ReadLine();
            this.TopNode = null;
            foreach (var c in S)
            {
                if (this.TopNode == null)
                {
                    this.TopNode = new Node(c);
                    this.LastNode = this.TopNode;
                }
                else
                {
                    this.LastNode = this.LastNode.AddChild(c);
                }
            }

            var Q = int.Parse(Console.ReadLine());
            var isReverse = false;
            foreach (var i in Enumerable.Range(0, Q))
            {
                var item = Console.ReadLine().Split();
                var type = item[0];
                if (type == "1")
                {
                    isReverse ^= true;
                }
                else
                {
                    var F = item[1];
                    var C = item[2];
                    if (!isReverse && F == "1" ||
                        isReverse && F == "2")
                    {
                        // 先頭に追加
                        this.TopNode = this.TopNode.AddParent(C[0]);
                    }
                    else
                    {
                        // 末尾に追加
                        this.LastNode = this.LastNode.AddChild(C[0]);
                    }
                }
            }

            var sb = new StringBuilder();
            if (!isReverse)
            {
                var node = this.TopNode;
                while (node != null)
                {
                    sb.Append(node.Value);
                    node = node.Child;
                }
            }
            else
            {
                var node = this.LastNode;
                while (node != null)
                {
                    sb.Append(node.Value);
                    node = node.Parent;
                }
            }

            Console.WriteLine(sb.ToString());
        }
    }
}


Measured memory_bytes: 31148