import java.util.Scanner

sealed trait Query
case object Reverse extends Query
case class Prepend(c: String) extends Query
case class Append(c: String) extends Query

object Main extends App {
  val sc = new Scanner(System.in)
  val s = sc.nextLine
  val q = sc.nextInt
  val queries = List.fill(q) {
    if (sc.nextInt == 1) Reverse
    else
      if (sc.nextInt == 1) Prepend(sc.next)
      else Append(sc.next)
  }

  @scala.annotation.tailrec
  def f(a: List[Query]): List[Query] = {
    a match {
      case Reverse +: Reverse +: tail => f(tail)
      case Reverse +: Prepend(c) +: tail => f(Append(c) +: tail)
      case Reverse +: Append(c) +: tail => f(Prepend(c) +: tail)
      case _ => a
    }
  }

  lazy val str = f(queries).foldLeft(s)((z, query) => {
    query match {
      case Reverse => z.reverse
      case Prepend(c) => c + z
      case Append(c) => z + c
    }
  })

  println(str)
}
