import scala.io.StdIn._

object Main extends App {

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

  def solve() = {
    val (str, reverseCnt) = Q.foldLeft((s, 0)) { case ((acc, reverseCnt), q) =>
      if(q.length == 1) (acc, reverseCnt+1)
      else (f(q(2), acc, reverseCnt, q(1)), reverseCnt)
    }
    if(reverseCnt % 2 == 0) str else str.reverse
  }

  def f(chr: String, str: String, reverseCnt: Int, direction: String): String = {
    val isHead = direction == "1"
    if(reverseCnt % 2 == 0)
      if(isHead) chr + str else str + chr
    else
      if(isHead) str + chr else chr + str
  }

  println(solve())

}

