import java.util.*

fun main(args: Array<String>) = abc158d()

fun abc158d() {
    val s = readLine()!!
    val q = readLine()!!.toInt()

    val stack = ArrayDeque(s.toList())
    var reversed = false

    for (i in 1..q) {
        val t = readLine()!!.split(' ')
        when (t[0].toInt()) {
            1 -> {
                reversed = !reversed
            }
            else -> {
                val f = t[1].toInt()
                val c = t[2][0]
                when (f) {
                    1 -> {
                        if (reversed) stack.addLast(c) else stack.addFirst(c)
                    }
                    else -> {
                        if (!reversed) stack.addLast(c) else stack.addFirst(c)
                    }
                }
            }
        }
    }

    val answer = (if (reversed) stack.reversed() else stack).joinToString("")

    println(answer)
}
