function Main(input){
	var temp = input.trim().split("\n");
  	var S = temp[0];
  	var Q = parseInt(temp[1],10);
	var q_start = 2
  	for(var i = 0;i<Q;i++){
      	var row = temp[q_start+i].split(" ");
      	switch(parseInt(row[0],10)){
          case 1:
            S = reversestr(S);
            //console.log("case 1:" + S);
            break;
          case 2:
            S = addstr(S,row[2],parseInt(row[1],10));
            //console.log(row[2],row[1] + "case 2 :" + S);
            break;
          default:
            break;
        }
    }//for
  	console.log(S);
}
function reversestr(str){
	str = str.split("").reverse().join("");
  	return str;
}
function addstr(str,addstr,p){
	if(p == 1){
    	str = addstr + str;
    }else if(p == 2){
    	str = str + addstr;
    }
  	return str;
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));