import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    var s = in.readLine()
    val q = in.readLine().toInt

    var reverse = false

    for {
      _ <- 0 until q
    } {
      in.readLine().split("\\s+") match {
        case Array("1") =>
          reverse = !reverse
        case Array("2", f, c) =>
          if (f == "1" && !reverse || f == "2" && reverse) {
            s = "" + c + s
          } else {
            s = s + c
          }
      }
    }

    out.println(
      if (reverse) {
        s.reverse
      } else {
        s
      }
    )
    out.flush()
  }
}
