// inputに入力データ全体が入る
function Main(input) {
    var list = new List();
    input[0].split("").forEach(v=>{
        list.addLast(v);
    });

    var s = 0;  
    var Q = input[1]-0;
    for(var i=2;i<Q+2;i++){
        var n = input[i].split(" ");
        if(n[0]=="1"){
            s = 1-s;
        }else{
            if(n[1] == "1"){
                if(s==0){
                    list.addFirst(n[2]);
                }else{
                    list.addLast(n[2]);
                }
            }else{
                if(s==1){
                    list.addFirst(n[2]);
                }else{
                    list.addLast(n[2]);
                }
            }
        }
    }
    console.log(list.toString(s));
}

function Node(v){
    this.val = v;
    this.next=null;
    this.prev=null;
}

function List(){
    this.length = 0;
    this.last=this.first=new Node("");
}
List.prototype.toString = function(s){
    var ans = "";
    if(s==0){
        var now = this.first;
        ans += now.val;
        while(now.next){
            now = now.next;
            ans += now.val;
        }
    }else{
        var now = this.last;
        ans += now.val;
        while(now.prev){
            now = now.prev;
            ans += now.val;
        }
    }
    return ans;
}
List.prototype.addLast = function(v){
    var newNode = new Node(v);
    this.last.next = newNode;
    newNode.prev = this.last;
    this.last = newNode;
    this.length++;
}
List.prototype.addFirst = function(v){
    var newNode = new Node(v);
    this.first.prev = newNode;
    newNode.next = this.first;
    this.first = newNode;
    this.length++;
}



Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n"));