object Main extends App {
  val buf = new StringBuilder
  val tmp = 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) {
      if (tmp.nonEmpty) {buf.append(tmp.reverse); tmp.clear()}
      reverse = !reverse
    }
    else if (t == 2) {
      val f = query(1).toInt
      val c = query(2)
      if (f == 1) {
        if (reverse) {
          buf.append(c)
      } else {
        tmp.append(c)
      }
      } else {
        if (reverse) {
          tmp.append(c)
        } else {
          buf.append(c)
        }
      }
    }
  }

  println(if (reverse) tmp.append(buf).toString() else tmp.append(buf.reverse).toString())
}