import std.stdio, std.conv, std.string, std.algorithm, std.math, std.array, std.container;

string s;
int q;

void main() {
  s = readln.chomp;
  readf("%d\n", &q);
  bool reversed = false;
  for(int i=0; i<q; i++) {
    string query = readln.chomp;
    if(query[0] == '1') reversed = !reversed;
    else {
      bool add_head = query[2]=='1';
      bool really_head = reversed!=add_head;
      if(really_head) s = query[4] ~ s;
      else s = s ~ query[4];
    }
  }
  if(reversed) {
    string s2 = std.algorithm.reverse(s.dup);
    s2.writeln;
  }
  else s.writeln;
}

