import java.util.*


fun main(args: Array<String>) {
    val ss = readLine()!!
    val q = getInt()

    val s: Deque<Char> = LinkedList()
    ss.forEach { s.addLast(it) }
    var reversed = false
    repeat(q) {
        val a = readLine()!!.split(" ")
        if (a[0][0] == '1') { // reverse
            reversed = !reversed
        } else {
            if (a[1][0] == '1') { // add ci to beginning
                if (reversed) {
                    s.addLast(a[2][0])
                } else {
                    s.addFirst(a[2][0])
                }
            } else { // add ci to end
                if (reversed) {
                    s.addFirst(a[2][0])
                } else {
                    s.addLast(a[2][0])
                }
            }
        }
    }

    if (reversed) {
        println(s.reversed().joinToString(""))
    } else {
        println(s.joinToString(""))
    }
}


fun getInt() = readLine()!!.toInt()
fun getInts() = readLine()!!.split(" ").map { it.toInt() }
fun getLong() = readLine()!!.toLong()
fun getLongs() = readLine()!!.split(" ").map { it.toLong() }
