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