function Main(input){
	var temp = input.trim().split("\n");
  	var S = temp[0];
  	var Q = parseInt(temp[1],10);
	var q_start = 2
    var Max = Math.ceil(Q/2);
  	for(var i = 0;i<Max;i++){
      	var row = (i+1 == Max && Q%2 === 1)?temp[q_start+(i*2)].split(" "):temp[q_start+(i*2)].split(" ").concat(temp[q_start+(i*2)+1].split(" "));
      	switch(row.length){
          case 6:
            S = addstr(S,row[2],parseInt(row[1],10));
            S = addstr(S,row[5],parseInt(row[4],10));
            break;
          case 4:
            if(row[0] == 2){
            	S = addstr(S,row[2],parseInt(row[1],10));
              	S = reversestr(S);
            }else{
              	S = reversestr(S);
              	S = addstr(S,row[3],parseInt(row[2],10));
            }
            break;
          case 3:
            S = addstr(S,row[2],parseInt(row[1],10));
            break;
          case 1:
            S = reversestr(S);
            break;
        }
    }//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"));