import java.util.Scanner

fun main(args: Array<String>){
  val scn = Scanner(System.`in`) //Scannerのインスタンスを作成
  
  var s: String = scn.next()
  val q: Int = scn.nextInt()
  var rev: Boolean = false
  var sb: Array<String?> = arrayOfNulls(q)
  var ib = 0
  var sa: Array<String?> = arrayOfNulls(q)
  var ia = 0
  for(i in 1..q) {
    val t: Int = scn.nextInt()
    if (t == 1) {
      rev = !rev
    } else {
      val f: Int = scn.nextInt()
      val c: String = scn.next()
      if (f == 1) {
        if (rev) {
          sa[ia] = c
          ia++
        } else {
          sb[ib] = c
          ib++
        }
      } else {
        if (rev) {
          sb[ib] = c
          ib++
        } else {
          sa[ia] = c
          ia++
        }
      }
    }
  }

  if (rev) {
    for(i in ia-1 downTo 0) print(sa[i])
    print(s.reversed())
    for(i in 0..ib-1) print(sb[i])
  } else {
    for(i in ib-1 downTo 0) print(sb[i])
    print(s)
    for(i in 0..ia-1) print(sa[i])
  }
  println("")
}