import scala.collection.mutable
import scala.io.StdIn._

object Main extends App {
  val S = readLine.toCharArray
  val Q = readInt


  var deque = mutable.DoubleLinkedList(S:_*)

  var reverse = false
  for (_ <- 0 until Q) {
    val query = readLine.split(" ")
    val T = query(0).toInt

    if (T.toInt == 1) {
      reverse = !reverse
    } else {
      val F = query(1).toInt
      val C = query(2).toString.charAt(0)

      val prepend = F == 1 && !reverse || F == 2 && reverse

      if (prepend) {
        deque = C +: deque
      } else {
        deque = deque :+ C
      }
    }
  }

  if (reverse) {
    println(deque.reverse.foldLeft[String](""){ case (acc, c) => acc + c })
  } else {
    println(deque.foldLeft[String](""){ case (acc, c) => acc + c })
  }
}

