import java.util.*

fun main(args: Array<String>) {
    val s = readLine() ?: return
    val q = readLine()?.toInt() ?: return
    var isReversed = false
    val result = LinkedList<String>()
    result.apply {
        s.forEach {
            addLast(it.toString())
        }
        repeat(q) {
            val query = readLine()?.split(" ") ?: return
            when (query[0].toInt()) {
                1 -> {
                    isReversed = !isReversed
                }
                2 -> {
                    val operationType = query.getOrNull(1)?.toInt() ?: return
                    val c = query.getOrNull(2) ?: return
                    when (operationType) {
                        1 -> {
                            if (isReversed) {
                                addLast(c)
                            } else {
                                addFirst(c)
                            }
                        }
                        2 -> {
                            if (isReversed) {
                                addFirst(c)
                            } else {
                                addLast(c)
                            }
                        }
                    }
                }
            }
        }
    }
    if (isReversed) {
        result.reverse()
    }
    println(result.joinToString(""))
}

