"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    let S = arg[0].split("");
    const N = parseInt(arg[1]);
    const Q = arg.slice(2, N + 2);
    
    let prev = [];
    let next = [];
    
    let flip = false;
    
    for(let i=0; i<N; i++) {
        const split = Q[i].split(" ");
        // Ti = 1の時、反転
        if(split.length === 1) {
            if(flip) {
                flip = false
            } else {
                flip = true;
            }
        } else {
            if(split[1] === "1") {
                if(!flip) {
                    prev.push(split[2]);
                } else {
                    next.push(split[2]);
                }
            } else {
                if(!flip) {
                    next.push(split[2]);
                } else {
                    prev.push(split[2]);
                }
            }
        }
        
        // console.log("flip;" + flip)
        // console.log("prev:" + prev);
        // console.log("next:" + next);
        // console.log("---")
    }
    

    if(flip) {
        console.log(next.reverse().join("") + S + prev.join(""));
    } else {
        console.log(prev.reverse().join("") + S + next.join(""));
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));