fun main(args: Array<String>) {
    val s = readLine()!!
    val q = readLine()!!.toInt()

    var reverseCount = 0
    val beforeList = mutableListOf<String>()
    val afterList = mutableListOf<String>()
    repeat(q) {
        val command = readLine()!!.split(" ")
        if (command.size == 1) {
            reverseCount += 1
            return@repeat
        }
        val isReversed = reverseCount % 2 == 1
        val str = command[2]

        if (isReversed) {
            if (command[1] == "1") {
                afterList.add(str)
            } else {
                beforeList.add(str)
            }
        } else {
            if (command[1] == "1") {
                beforeList.add(str)
            } else {
                afterList.add(str)
            }
        }
    }

    var ans = beforeList.joinToString("").reversed() + s + afterList.joinToString("")
    if (reverseCount % 2 == 1) {
        ans = ans.reversed()
    }
    println(ans)
}