import java.util.*

fun main(args : Array<String>) {
    val scan = Scanner(System.`in`)

    var s = scan.next()
    val q = Integer.parseInt(scan.next())

    var rvFlag = false
    var rvCnt = 0

    val front = ArrayDeque<String>()
    val end = ArrayDeque<String>()

    repeat(q) {
        val q1 = Integer.parseInt(scan.next())

        if (q1 == 1) {
            rvFlag = !rvFlag
            rvCnt++
        } else {
            val q2 = Integer.parseInt(scan.next())
            val c = scan.next()

            if (rvFlag) {
                if (q2 == 1) {
                    end.addLast(c)
                } else {
                    front.addFirst(c)
                }
            } else {
                if (q2 == 1) {
                    front.addFirst(c)
                } else {
                    end.addLast(c)
                }
            }
        }
    }

    s = front.joinToString(separator = "") + s + end.joinToString(separator = "")

    if (rvCnt % 2 == 1) {
        println(s.reversed())
    } else {
        println(s)
    }
}