import scala.collection.mutable

object Main extends App {
  val buf = new mutable.StringBuilder
  val tmp = new mutable.StringBuilder
  val s = io.StdIn.readLine()
  val q = io.StdIn.readLine().toInt
  var reverse = false
  buf.append(s)
  for (_ <- 0 until q) {
    val query = io.StdIn.readLine().split(' ')
    val t = query(0).toInt
    if (t == 1) {
      buf.reverseInPlace()
      if (tmp.nonEmpty) {buf.append(tmp.reverse); tmp.clear()}
    }
    else if (t == 2) {
      val f = query(1).toInt
      val c = query(2)
      if (f == 1) tmp.append(c)
      else buf.append(c)
    }
  }
  println(tmp.append(buf).toString())
}