#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

string base = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int N, M, Q;
    while (cin >> N >> M >> Q, N) {
        vector<string> S(Q + 1), B(Q + 1);
        S[0] = string(N, '0');
        B[0] = string(M, '0');
        rep(i, Q) {
            cin >> S[i + 1] >> B[i + 1];
        }

        vector<vector<bool>> a(N, vector<bool>(M, true));
        rep2(q, 1, Q + 1) {
            rep(i, N) {
                rep(j, M) {
                    if ((S[q][i] == '0') ^ (B[q][j] == B[q - 1][j])) {
                        a[i][j] = false;
                    }
                }
            }
        }

        rep(j, M) {
            int cnt = 0;
            int ans = -1;
            rep(i, N) {
                if (a[i][j]) {
                    cnt++;
                    ans = i;
                }
            }
            cout << (cnt == 1 ? base[ans] : '?');
        }
        cout << endl;

    }
}