fun main(args: Array<String>) {
    val s = readLine()!!
    val q = readLine()!!.toInt()
    val pre = StringBuilder()
    val post = StringBuilder()

    var isRev = false
    repeat(q) {
        val line = readLine()!!.split(' ')
        val t = line[0].toInt()
        if (t == 1) {
            isRev = !isRev
        } else {
            val f = line[1].toInt()
            val c = line[2][0]
            val isPre = (isRev && f == 2 || !isRev && f == 1)
            if (isPre) {
                pre.append(c)
            } else {
                post.append(c)
            }
        }
    }

    if (isRev) {
        println("${post.reversed()}${s.reversed()}${pre}")
    } else {
        println("${pre.reversed()}$s$post")
    }
}