#include <bits/stdc++.h>
using namespace std;
const int MAX_Q=1010,MAX_M=1010,MAX_N=37;

int N,M,Q;
string S[MAX_Q],B[MAX_Q];
string base,ans;
int check[MAX_M][MAX_N];

void solve(){
    for (int i=0;i<M;++i)
        for (int j=0;j<N;++j)
            check[i][j]=1;
    string now="";
    for (int i=0;i<N;++i) now+='0';
    for (int i=0;i<Q;++i){
        for (int j=0;j<N;++j)
            if (S[i][j]=='1')
                now[j]=(now[j]=='0'?'1':'0');
        for (int j=0;j<M;++j)
            for (int k=0;k<N;++k)
                if (B[i][j]!=now[k])
                    check[j][k]=0;
    }
    ans="";
    for (int i=0;i<M;++i){
        int button=-1;
        for (int j=0;j<N;++j) if (check[i][j]){
            if (button==-1) button=j;
            else button=-2;
        }
        ans+=(0<=button?base[button]:'?');
    }
    cout << ans << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    for (int i=0;i<10;++i) base+='0'+i;
    for (int i=0;i<26;++i) base+='A'+i;
    while(cin >> N >> M >> Q,N){
        for (int i=0;i<Q;++i) cin >> S[i] >> B[i];
        solve();
    }
}
