import scala.io.StdIn._

object Main extends App {

  val s = readLine()
  val qNum = readInt()
  val Q = Array.fill(qNum)(readLine().split(" "))

  def solve() = {
    Q.foldLeft(s) { (acc, q) =>
      if(q.length == 1) acc.reverse
      else {
        if(q(1) == "1") q(2) + acc
        else acc + q(2)
      }
    }
  }

  println(solve())

}

