import java.util.ArrayDeque

fun main(args: Array<String>) {
    val queue = ArrayDeque<Char>(200000)
    val S = readInputLine().toCharArray().forEach { queue.addLast(it) }
    val Q = readInputLine().toInt()

    var former = true

    repeat(Q) {
        val query = readInputLine().split(" ")
        when (query[0]) {
            "1" -> {
                former = !former
            }
            else -> {
                val F = query[1]
                val C = query[2]
                val addFirst = (F == "1" && former) || (F == "2" && !former)
                if (addFirst) {
                    queue.addFirst(C.first())
                } else {
                    queue.addLast(C.first())
                }
            }
        }
    }

    while (queue.isNotEmpty()) {
        print(if (former) queue.pollFirst()!! else queue.pollLast()!!)
    }
    println()
}

fun readInputLine(): String {
    return readLine()!!
}
