object Main extends App {
  val s = scala.io.StdIn.readLine()
  val q = scala.io.StdIn.readInt()
  def hanten(input: String) = {
    val strBuffer = new StringBuffer(input)
    strBuffer.reverse().toString
  }

  var result = s
  var hantenFlg = false
  (1 to q).foreach { _ =>
    val query = scala.io.StdIn.readLine()
    if (query == "1") {
      hantenFlg = if (hantenFlg) false else true
    } else {
      val querySplit = query.split(" ")
      if (querySplit(1) == "1") {
        result = querySplit(2) + (if (hantenFlg) hanten(result) else result)
      } else {
        result = (if (hantenFlg) hanten(result) else result) + querySplit(2)
      }
      hantenFlg = false
    }
  }

  println(if (hantenFlg) hanten(result) else result)
}