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(" ");
      	S = parseInt(row[0],10) === 1?reversestr(S):addstr(S,row[2],parseInt(row[1],10));
    }//for
  	console.log(S);
}
function reversestr(str){
	str = str.split("").reverse().join("");
  	return str;
}
function addstr(str,addstr,p){
  	str = p===1?addstr + str:str+addstr;
  	return str;
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));