import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val s = sc.nextLine
    val q = sc.nextInt()
    sc.nextLine()

    var reversed = false
    val prefix = new ArrayBuffer[String]()
    val suffix = new ArrayBuffer[String]()

    for (i <- 0 until q) {
      val line = sc.nextLine()
      val t = line.split(" ")(0).toInt
      if (t == 1) {
        reversed = !reversed
      } else {
        val f = line.split(" ")(1).toInt
        val c = line.split(" ")(2)
        if (f == 1) {
          if (!reversed) {
            prefix.append(c)
          } else {
            suffix.append(c)
          }
        } else {
          if (!reversed) {
            suffix.append(c)
          } else {
            prefix.append(c)
          }
        }
      }
    }


    val ans = if (!reversed) {
      (prefix.toList.reverse ++ s ++ suffix).mkString("")
    } else {
      (suffix.toList.reverse ++ s.reverse ++ prefix).mkString("")

    }
    println(ans)

  }
}
