const main = (inputs) => {
  const firstWord = inputs[0];
  const count = Number(inputs[1]) + 2;
  var answer = [];
  answer.push(firstWord);

  for (var i = 2; i < count; i++) {
    var command = inputs[i].split(" ");
    if (command.length === 3) {
      if (Number(command[1]) === 1) {
        answer.unshift(command[2]);
      } else {
        answer.push(command[2]);
      }
    } else {
      answer = answer.reverse();
    }
  }

  console.log(answer.join(''));
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));