import java.util.*

fun main(args: Array<String>) {
  val s = StringBuilder(readLine()!!)
  val t = StringBuilder()
  val q = readLine()!!.toInt()
  var r = 0
  repeat(q) {
    val query = readLine()!!
    if (query[0] == '1') {
      r++
    } else {
      val a = query[2] == '1'
      val b = r % 2 == 0
      if ((a && b) || (!a && !b)) {
        t.append(query[4])
      } else {
        s.append(query[4])
      }
    }
  }
  if (r % 2 == 0) {
    println(t.reverse().append(s))
  } else {
    println(s.reverse().append(t))
  }
}
