var s:String = readLine()!
let q:Int = Int(readLine()!)!
var c1:Int = 1
var s1:String = ""
var s2:String = ""
for _ in 0..<q {
  let query = readLine()!
  if query.contains(" ") {
    let l = query.split(separator:" ")
    let c2 = (l[1] == "1" ? 1:-1)
    if c1*c2 == 1 {
      s1 += l[2]
    } else {
      s2 += l[2]
    }
  } else {
    c1 = -c1
  }
}
s = String(s1.reversed()) + s + s2
print(c1 == 1 ? s:String(s.reversed()))