import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.container.dlist;

alias DL = DList!char;

class P {
  DL l;
  void add (int f, char c) {
    if (!f) {
      l.insertFront (c);
    } else {
      l.insertBack (c);
    }
  }
}

class S {
  string s;
  int rev;
  P prefix;
  P suffix;
  this (string _s) { 
    s = _s; 
    prefix = new P ();
    suffix = new P ();
  }
  void reverse () {
    ++rev;
  }
  void add (int f, char c) {
    if (!(rev & 1)) {
      if (f == 1) prefix.add (0, c);
      else suffix.add (1, c);
    } else {
      if (f == 2) prefix.add (0, c);
      else suffix.add (1, c);
    }
  }
  void dump () {
    if (!(rev & 1)) {
      foreach (c; prefix.l) write (c);
      write (s);
      foreach (c; suffix.l) write (c);
    } else {
      foreach_reverse (c; suffix.l) write (c);
      foreach_reverse (c; s) write (c);
      foreach_reverse (c; prefix.l) write (c);
    }
    writeln;
  }
  
}


void main() {
  auto s = readln.stripRight;
  auto z = readln.stripRight;
  const int nt = z.to!int;
  auto res = new S (s);
  foreach (tid; 0 .. nt) {
    z = readln.stripRight;
    auto w = z.splitter;
    const int t = w.front.to!int;
    w.popFront ();
    if (t == 1) {
      res.reverse ();
    } else {
      int f = w.front.to!int;
      w.popFront ();
      char c = w.front[0]; 
      res.add (f, c);
    }
    //res.dump ();
  }
  res.dump ();
}

