var s:String = readLine()!
let q:Int = Int(readLine()!)!
var c1:Int = 1
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 {
      s = l[2] + s
    } else {
      s += l[2]
    }
  } else {
    c1 = -c1
  }
}
print(c1 == 1 ? s:String(s.reversed()))