private fun solve() {
    val S = readLine()!!
    val (Q) = readInts()

    val text = java.util.ArrayDeque<Char>(100004)
    S.forEach { text.addLast(it) }

    var reversed = false
    Q.repeat {
        val queue = readLine()!!

        if (queue[0] == '1') {
            reversed = !reversed
        } else {
            val (_t, _f, _c) = queue.split(" ")
            val f = _f.toInt()
            val c = _c[0]

            // xor
            if ((f == 1) != reversed) text.addFirst(c) else text.addLast(c)
        }
    }

    println((if (reversed) text.reversed() else text).joinToString(separator = ""))
}

fun main(args: Array<out String>) = solve()
private fun readAtOnce(): List<String> = readLine()!!.split(" ")
private fun readInts(): List<Int> = readAtOnce().map(String::toInt)
private fun readLongs(): List<Long> = readAtOnce().map(String::toLong)
private fun zeroArray(size: Int): IntArray = IntArray(size) { 0 }
private fun Int.repeat(predicate: (Int) -> Unit) = repeat(this, predicate)