import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun main() {

    fun PrintWriter.solve() {
        var s = next()
        var rev = false

        var q = ArrayDeque<Char>()
        q.addAll(s.toList())
        repeat(nextInt()){
            var line = nextLine().split(" ")
            if (line.size == 1){
                rev = !rev
            }
            else{
                var addToFront = if ((line[1].equals("1") and !rev )|| (line[1].equals("2") and rev) ) true else false

                if (addToFront)q.addFirst(line[2][0])
                else q.addLast(line[2][0])
            }

        }

        var sb = StringBuilder(q.joinToString(""))
        if (rev)sb.reverse()

        println(sb.toString())


    }

    writer.solve()
    writer.flush()


}


private val reader = System.`in`.bufferedReader()
private val writer = PrintWriter(System.out, false)

private var tokenizer: StringTokenizer = StringTokenizer("")

private fun next(): String {
    while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(reader.readLine())
    return tokenizer.nextToken()
}

private fun nextInt() = next().toInt()
private fun nextLong() = next().toLong()
private fun nextDouble() = next().toDouble()
private fun nextLine() = reader.readLine()

