import java.util

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

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


  val deque = new util.ArrayDeque[Char](util.Arrays.asList(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).charAt(0)

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

      if (prepend) {
        deque.addFirst(C)
      } else {
        deque.addLast(C)
      }
    }
  }

  val sb = new mutable.StringBuilder()
  while (!deque.isEmpty) {
    if (!reverse) {
      sb.append(deque.removeFirst())
    } else {
      sb.append(deque.removeLast())
    }
  }

  println(sb.toString())
}


