"use strict";
function main(input) {
  let s = input[0];
  let q = parseInt(input[1]);

  let tag = false;

  let f = "";
  let c = "";

  for(let i=0;i<q;i++){
    let kari = input[i+2].trim().split(" ");
    let query = kari[0];

    if(query==="1"){
      tag = !tag;
    }else{
      f = kari[1];
      c = kari[2];
      if(f === "1"){
        if(tag){
          s = s + c;
        }else{
          s = c + s;
        }
      }else{
        if(tag){
          s = c + s;
        }else{
          s = s + c;
        }
      }
    }
  }

  if(tag){
    s = s.split("").reverse().join("");
  }
  console.log(s);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));