process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
  var str = lines[0];
  const Q = Number(lines[1]);
  for (let i = 0; i < Q; i++) {
    let input = lines[2+i];
    if (input[0] === "1") str = str.split("").reverse().join("");
    else {
      let op2 = input[2];
      let char = input[4];
      str = input[2] === "1" ? char+str : str+char;
    }
  }
  console.log(str);
});
