import java.util.Scanner

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    var head = mutableListOf<Char>()
    var tail = sc.next().toMutableList()
    val Q = sc.nextInt()
    for (i in 1..Q) {
        val T = sc.nextInt()
        if (T == 1) {
            val tmp = head
            head = tail
            tail = tmp
        } else {
            val F = sc.nextInt()
            val C = sc.next().first()
            if (F == 1) {
                head.add(C)
            } else {
                tail.add(C)
            }
        }
    }
    val ans = head.joinToString(separator = "").reversed() + tail.joinToString(separator = "")
    println(ans)
}