import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val S = in.next()
  val Q = in.next().toInt

  var vec = S.toVector
  var flag = 0

  for (_ <- 1 to Q) {
    val com = in.next().toInt

    if (com == 1) {
      flag += 1
      flag %= 2
    }
    else if (com == 2) {
      val p = in.next().toInt
      val c = in.next()(0)

      if (flag == 0) {
        if (p == 1)
          vec = c +: vec
        else
          vec = vec :+ c
      }
      else if (flag == 1) {
        if (p == 1)
          vec = vec :+ c
        else
          vec = c +: vec
      }

    }
  }


  val ans = vec.mkString
  if (flag == 0) {
    println(ans)
  }
  else {
    println(ans.reverse)
  }
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
