const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')
const S = lines[0]
const Q = lines[1] - 0

const f = str => {
    let s = ''
    for (let i = str.length - 1; i >= 0; i--) {
        s += str[i]
    }
    return s
}

let dir = 1
let pre = ''
let suf = ''
for (let i = 2; i < Q + 2; i++) {
    const q = lines[i].split(' ')
    if (q[0] == 1) {
        dir = dir % 2 + 1
    } else {
        if (q[1] == dir) {
            pre += q[2]
        } else {
            suf += q[2]
        }
    }
}

const s = f(pre) + S + suf
console.log(dir == 1 ? s : f(s))