"use strict";

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

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