import scala.annotation.tailrec
object Main extends App {
  import scala.io.StdIn._
  val map = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".zipWithIndex.map{case (c, i) ⇒ (1L << i, c)}.toMap
  loop()
  @tailrec def loop(): Unit = {
    val Array(n, m, q) = readLine.trim.split(' ').map(_.toInt)
    if (n == 0 && m == 0 && q == 0) return
    val bulbs = Array.fill(m){(1L << n) - 1}
    var switch = 0L
    for (_ ← 0 until q){
      val Array(s, b) = readLine.trim.split(' ')
      switch ^= java.lang.Long.parseLong(s.reverse, 2)
      for (i ← b.indices) {
        bulbs(i) &= (if (b(i) == '1') switch else ~switch)
      }
    }
    println(bulbs.map(map.getOrElse(_, '?')).mkString(""))
    loop()
  }
}
