def inv(bit,m)
    bs = bit.to_s(2)
    if bs.length < m
        bs = "0" * (m - bs.length) + bs
    end
    ret = ""
    bs.each_char do |c|
        ret << (c == "0" ? "1" : "0")
    end
    ret.to_i(2)
end
conv = ('0'..'9').to_a + ('A'..'Z').to_a
loop do
    n, m, q = gets.split.map(&:to_i)
    break if n == 0 && m == 0 && q == 0
    cor = Array.new(m,2**n-1)
    prev = 0
    q.times do
        input = gets.chomp.split
        s = input[0].to_i(2)
        b = prev ^ input[1].to_i(2)
        bs = b.to_s(2)
        if bs.length < m
            bs = "0" * (m - bs.length) + bs
        end
        inv = inv(s,n)
        bs.each_char.with_index do |bit,i|
            if bit == "1"
                cor[i] &= s
            else
                cor[i] &= inv
            end
        end
        prev = input[1].to_i(2)
    end
    ret = ""
    cor.each do |c|
        if c & (c-1) != 0
            ret << "?"
        else
            t = n - 1 - Math.log2(c).to_i
            ret << conv[t]
        end
    end
    puts ret
end