"use strict";

const main = arg => {
    const input = arg.trim().split("\n");

    let s = input[0].split(" ");
    const QN = parseInt(input[1]);
    let front = []
    let back = []
    let isReverse = false
    for(let i = 2; i<2+QN; i++){
        let q = input[i].split(" ")
        if(q[0] == 1){
            isReverse = !isReverse
        } else {
            if(q[1] == 1){
                if(isReverse) back.push(q[2])
                else front.push(q[2])
            } else {
                if(isReverse) front.push(q[2])
                else back.push(q[2])
            }
        }
    }
    if(isReverse){
        s.reverse()
        back.reverse()
        console.log(back.join("") + s.join("") + front.join(""))
    }else{
        front.reverse()
        console.log(front.join("")+s.join("")+back.join(""))
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  