inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
s = inp.shift()
N = inp.shift() * 1
f = 0
p = []
e = []
for (i=0; i<N; i++) {
    l = inp.shift().split(" ")
    if (l[0] == 1) {
        f++
    } else {
        if (l[1] == 1) {
            if (f % 2 === 0) {
                p.push(l[2])
            } else {
                e.push(l[2])
            }
        } else {
            if (f % 2 === 1) {
                p.push(l[2])
            } else {
                e.push(l[2])
            }
        }
    }
}
if (f % 2) {
    for (i = 0; i < e.length; i++) {
        process.stdout.write(e[e.length - i - 1])
    }
    for (i = 0; i < s.length; i++) {
        process.stdout.write(s[s.length - i - 1])
    }
    for (i = 0; i < p.length; i++) {
        process.stdout.write(p[i])
    }
} else {
    for (i = 0; i < p.length; i++) {
        process.stdout.write(p[p.length - i - 1])
    }
    for (i = 0; i < s.length; i++) {
        process.stdout.write(s[i])
    }
    for (i = 0; i < e.length; i++) {
        process.stdout.write(e[i])
    }
}
process.stdout.write("\n")