"use sict"
function main(arg) {
    let d = arg.trim().split("\n")
    let s = d[0]
    d.shift()
    d.shift()
    let f = true
    for (let i = 0; i < d.length; i++) {
        const r = d[i].split(' ')
        if (r[0] === '1') f = !f
        if (r[0] === '2') {
            if (r[1] === '1') {
                if (f) s = r[2] + s
                else s += r[2]
            }
            if (r[1] === '2') {
                if (f) s += r[2]
                else s = r[2] + s
            }
        }
    }
    if (!f) s = s.split('').reverse().join('')
    console.log(s)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))
