import java.util.*

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

    val s = sc.nextLine()
    val n = sc.nextInt()


    var list = LinkedList<String>()
    list.addFirst(s)
    var isReverse = false

    for(i in 0 until n){
        val q = sc.nextInt()
        if(q == 1){
//            a = a.reversed()
            isReverse = !isReverse
        } else if(q == 2){
            val t = sc.nextInt()
            val c = sc.next()

            if(t == 1){
                if(isReverse){
//                    a = a + c
                    list.addLast(c)
                } else {
//                    a = c + a
                    list.addFirst(c)
                }
            }
            if(t == 2){
                if(isReverse){
//                    a = c + a
                    list.addFirst(c)
                } else {
//                    a = a + c
                    list.addLast(c)
                }
            }
        }
    }

    if(isReverse) {
//        a = a.reversed()
        list.reverse()
        list.forEach {
            if(it.length > 1){
                print(it.reversed())
            } else {
                print(it)
            }
        }
    } else {

        list.forEach(::print)
    }


//    println(a)


}
