import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val s = sc.next()
  val q = sc.nextInt()

  val front = mutableListOf<String>()
  val back = mutableListOf<String>()
  var order = true
  for (i in 1..q) {
    val ti = sc.nextInt()
    if (ti == 1) {
      order = !order
    } else {
      val fi = sc.nextInt()
      val ci = sc.next()
      if ((order && fi ==1) || (!order && fi == 2)) {
        front.add(ci)
      } else {
        back.add(ci)
      }
    }
  }

  var ans = front.reversed().joinToString("") + s + back.joinToString("")

  if (order) {
    println(ans)
    return
  }
  println(ans.reversed())
}