
fun main(args: Array<String>) {
    val S = readLine()!!
    val Q = readLine()!!.toInt()
    // var isReversed = false
    val queries = (1..Q).map {
        val line = readLine()!!.split(" ")
        if(line.size > 1) {
            Pair(line[0].toInt(), Pair(line[1].toInt(), line[2]))
        } else {
            Pair(line[0].toInt(), null)
        }
    }
    val when_fliped_pairs = mutableListOf<Pair<Int, Pair<Int, String>>>()
    var flip_counter = 0
    for(query in queries) {
        flip_counter += if(query.first == 1) {1} else {0}
        query.second?.run {
             when_fliped_pairs.add(Pair(flip_counter, this)) 
        }
    }
    val prefix_appendees = mutableListOf<String>()
    val suffix_appendees = mutableListOf<String>()
    for(query in when_fliped_pairs) {
        when(Pair((flip_counter - query.first) % 2 == 0, query.second.first == 1)) {
                   Pair(false, false), Pair(true, true) -> {
                    prefix_appendees.add(query.second.second)
                }
                else -> {
                    suffix_appendees.add(query.second.second)
                }
        }
    }
   (prefix_appendees.reversed().joinToString("") + if(flip_counter % 2 == 1) { S.reversed() } else { S } + suffix_appendees.joinToString("")).run(::println)
}