object Main extends App {
  val buf = new 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) reverse = !reverse
    else if (t == 2) {
      val f = query(1).toInt
      val c = query(2)
      if (f == 1) {if (reverse) buf.append(c) else buf.insert(0, c)}
      else {if (reverse) buf.insert(0, c) else buf.append(c)}
    }
  }
  println(if (reverse) buf.reverse.toString() else buf.toString())
}