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

partial class Solver {
    public void Run() {
        var s = ns();
        var q = ni();

        var treap = new Treap();
        foreach (var c in s) {
            treap.Add(new TreapNode(c));
        }
        for (int _ = 0; _ < q; _++) {
            var t = ni();
            if (t == 1) {
                treap.Reverse(0, treap.Count);
            } else {
                var f = ni();
                var c = ns()[0];
                if (f == 1) {
                    treap.Insert(0, new TreapNode(c));
                } else {
                    treap.Add(new TreapNode(c));
                }
            }
        }
        var ans = new string(Treap.Extract(treap.Root, 0, treap.Count).Select(a => a.Value).ToArray());
        cout.WriteLine(ans);
    }
}

public class TreapNode {
    public TreapNode Left;
    public TreapNode Right;
    public TreapNode Parent;
    public char Value;
    public int Priority;
    public int Size;
    public bool lazyReverse;
    private static readonly Random random = new Random(1);

    public TreapNode(char value) {
        Value = value;
        Priority = random.Next();
        Size = 1;
    }

    public void Reverse() {
        var tmp = Left;
        Left = Right;
        Right = tmp;
    }
}

public class Treap {
    public TreapNode Root = null;

    private static void LazyPropagation(TreapNode node) {
        if (node == null) {
            return;
        }

        if (node.lazyReverse) {
            node.lazyReverse = false;
            node.Reverse();
            if (node.Left != null) {
                node.Left.lazyReverse ^= true;
            }

            if (node.Right != null) {
                node.Right.lazyReverse ^= true;
            }
        }
    }

    private static int Size(TreapNode node) {
        return node == null ? 0 : node.Size;
    }

    private static TreapNode Update(TreapNode node) {
        if (node == null) {
            return null;
        }

        LazyPropagation(node);
        node.Size = Size(node.Left) + Size(node.Right) + 1;
        return node;
    }

    private static TreapNode Merge(TreapNode left, TreapNode right) {
        LazyPropagation(left);
        LazyPropagation(right);
        if (left == null || right == null) {
            return left == null ? right : left;
        }

        if (left.Priority > right.Priority) {
            left.Right = Merge(left.Right, right);
            if (left.Right != null) {
                left.Right.Parent = left;
            }

            return Update(left);
        } else {
            right.Left = Merge(left, right.Left);
            if (right.Left != null) {
                right.Left.Parent = right;
            }

            return Update(right);
        }
    }

    private static Tuple<TreapNode, TreapNode> Split(TreapNode node, int k) {
        if (node == null) {
            return new Tuple<TreapNode, TreapNode>(null, null);
        }

        LazyPropagation(node);
        if (k <= Size(node.Left)) {
            var s = Split(node.Left, k);
            node.Left = s.Item2;
            if (node.Left != null) {
                node.Left.Parent = node;
            }

            return new Tuple<TreapNode, TreapNode>(s.Item1, Update(node));
        } else {
            var s = Split(node.Right, k - Size(node.Left) - 1);
            node.Right = s.Item1;
            if (node.Right != null) {
                node.Right.Parent = node;
            }

            return new Tuple<TreapNode, TreapNode>(Update(node), s.Item2);
        }
    }

    private static TreapNode Insert(TreapNode node, int k, TreapNode newNode) {
        LazyPropagation(node);
        var s = Split(node, k);
        return Update(Merge(Merge(s.Item1, newNode), s.Item2));
    }

    private static TreapNode Erase(TreapNode node, int k) {
        LazyPropagation(node);
        var s2 = Split(node, k + 1);
        var s1 = Split(s2.Item1, k);
        return Update(Merge(s1.Item1, s2.Item2));
    }

    private static TreapNode SwapRange(TreapNode node, int begin1, int end1, int begin2, int end2) {
        LazyPropagation(node);
        var s1 = Split(node, begin1);
        var s2 = Split(s1.Item2, end1 - begin1);
        var s3 = Split(s2.Item2, begin2 - end1);
        var s4 = Split(s3.Item2, end2 - begin2);
        node = Merge(s1.Item1, s4.Item1);
        node = Merge(node, s3.Item1);
        node = Merge(node, s2.Item1);
        node = Merge(node, s4.Item2);
        return Update(node);
    }

    private static TreapNode Rotate(TreapNode node, int begin, int end) {
        LazyPropagation(node);
        var s1 = Split(node, begin + 1);
        var s2 = Split(s1.Item1, begin);
        var s3 = Split(s1.Item2, end - begin - 1);
        return Update(
            Merge(Merge(Merge(s2.Item1, s3.Item1), s2.Item2), s3.Item2)
        );
    }

    private static TreapNode Find(TreapNode node, int k) {
        LazyPropagation(node);
        int c = Size(node.Left);
        if (k < c) {
            return Find(node.Left, k);
        }

        if (k > c) {
            return Find(node.Right, k - c - 1);
        }

        return node;
    }

    private static TreapNode Reverse(TreapNode node, int begin, int end) {
        var s2 = Split(node, end);
        var s1 = Split(s2.Item1, begin);
        var segment1 = s1.Item1;
        var segment2 = s1.Item2;
        var segment3 = s2.Item2;
        segment2.lazyReverse ^= true;
        LazyPropagation(segment2);
        return Update(Merge(Merge(segment1, segment2), segment3));
    }

    public static int IndexOf(TreapNode node) {
        int index = 0;
        var path = new List<TreapNode>();
        while (node != null) {
            path.Add(node);
            node = node.Parent;
        }
        path.Reverse();
        path.ForEach(LazyPropagation);
        for (int i = 0; i < path.Count; i++) {
            if (i + 1 < path.Count) {
                if (path[i].Right == path[i + 1]) {
                    index += Size(path[i].Left) + 1;
                }
            } else {
                index += Size(path[i].Left);
            }
        }
        return index;
    }

    public static void Extract(TreapNode node, List<TreapNode> step, int begin, int end, ref int current) {
        if (current >= end || node == null) {
            return;
        }

        LazyPropagation(node);
        if (current + Size(node) < begin) {
            current += Size(node);
            return;
        }
        Extract(node.Left, step, begin, end, ref current);
        if (begin <= current && current < end) {
            step.Add(node);
        }

        current++;
        Extract(node.Right, step, begin, end, ref current);
    }

    public static IEnumerable<TreapNode> Extract(TreapNode node, int begin, int end) {
        int current = 0;
        var step = new List<TreapNode>();
        Extract(node, step, begin, end, ref current);
        return step;
    }

    public void Add(TreapNode node) {
        Insert(Count, node);
    }

    public void Insert(int k, TreapNode newNode) {
        Root = Insert(Root, k, newNode);
    }

    public void RemoveAt(int k) {
        Root = Erase(Root, k);
    }

    public void Rotate(int begin, int end) {
        if (begin >= end) {
            throw new ArgumentException();
        }

        Root = Rotate(Root, begin, end);
    }

    public void SwapRange(int begin1, int end1, int begin2, int end2) {
        Root = SwapRange(Root, begin1, end1, begin2, end2);
    }

    public int Count {
        get {
            return Size(Root);
        }
    }

    public TreapNode Find(int k) {
        return Find(Root, k);
    }

    public void Reverse(int begin, int end) {
        if (begin >= end) {
            throw new ArgumentException();
        }

        Root = Reverse(Root, begin, end);
    }
}

// PREWRITEN CODE BEGINS FROM HERE
partial class Solver : Scanner {
    public static void Main(string[] args) {
        new Solver(Console.In, Console.Out).Run();
    }

    TextReader cin;
    TextWriter cout;

    public Solver(TextReader reader, TextWriter writer)
        : base(reader) {
        this.cin = reader;
        this.cout = writer;
    }
    public Solver(string input, TextWriter writer)
        : this(new StringReader(input), writer) {
    }

    public int ni() { return NextInt(); }
    public int[] ni(int n) { return NextIntArray(n); }
    public long nl() { return NextLong(); }
    public long[] nl(int n) { return NextLongArray(n); }
    public double nd() { return NextDouble(); }
    public string ns() { return Next(); }
}

public class Scanner {
    private TextReader Reader;
    private Queue<String> TokenQueue = new Queue<string>();
    private readonly CultureInfo ci = CultureInfo.InvariantCulture;

    public Scanner()
        : this(Console.In) {
    }

    public Scanner(TextReader reader) {
        this.Reader = reader;
    }

    public int NextInt() { return Int32.Parse(Next(), ci); }
    public long NextLong() { return Int64.Parse(Next(), ci); }
    public double NextDouble() { return double.Parse(Next(), ci); }
    public string[] NextArray(int size) {
        var array = new string[size];
        for (int i = 0; i < size; i++) array[i] = Next();
        return array;
    }
    public int[] NextIntArray(int size) {
        var array = new int[size];
        for (int i = 0; i < size; i++) array[i] = NextInt();
        return array;
    }

    public long[] NextLongArray(int size) {
        var array = new long[size];
        for (int i = 0; i < size; i++) array[i] = NextLong();
        return array;
    }

    public String Next() {
        if (TokenQueue.Count == 0) {
            if (!StockTokens()) throw new InvalidOperationException();
        }
        return TokenQueue.Dequeue();
    }

    public bool HasNext() {
        if (TokenQueue.Count > 0)
            return true;
        return StockTokens();
    }

    private bool StockTokens() {
        while (true) {
            var line = Reader.ReadLine();
            if (line == null) return false;
            var tokens = line.Trim().Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (tokens.Length == 0) continue;
            foreach (var token in tokens)
                TokenQueue.Enqueue(token);
            return true;
        }
    }
}


Measured memory_bytes: 45084