import java.util.*

fun main(args:Array<String>){
    solve()
}

fun solve(){
    val s = read().toCharArray()
    val ans = ArrayDeque<Char>()
    s.forEach{
        ans.addLast(it)
    }
    var dir = true
    val q = readint()
    repeat(q){
        val a = reads()
        if(a[0] == "1"){
            dir = !dir
        }
        else{
            val f = a[1].toInt()
            if(f == 1){
                if(dir){
                    ans.addFirst(a[2][0])
                }
                else{
                    ans.addLast(a[2][0])
                }
            }
            else{
                if(!dir){
                    ans.addFirst(a[2][0])
                }
                else{
                    ans.addLast(a[2][0])
                }
            }
        }
    }
    val res = StringBuilder()
    if(dir){
        while(ans.isNotEmpty()){
            res.append(ans.first)
            ans.removeFirst()
        }
    }
    else{
        while(ans.isNotEmpty()){
            res.append(ans.last)
            ans.removeLast()
        }
    }
    println(res)
}

fun read() = readLine()!!
fun reads() = readLine()!!.split(" ")
fun readint() = readLine()!!.toInt()
fun readints() = readLine()!!.split(" ").map{it.toInt()}
fun readlong() = readLine()!!.toLong()
fun readlongs() = readLine()!!.split(" ").map{it.toLong()}