object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  val ls = in.map(e => e.split(' ').toArray).toArray
  val S = ls(0)(0)
  val list = ls.tail.tail
  
  var state = false
  var str = List(S(0).toChar)
  var rev = List[Char]()
  list.foreach{ line =>
    if(line(0) == "1") state = !state
    else{
      val is = (line(1) == "1") ^ state
      val add = (line(2))(0).toChar
      if(is) str = add :: str else rev = add :: rev
    }
    //println(rev, str)    
  }
  print(rev.mkString)
  println(str.mkString)
}
