#include <iostream>
#include <vector>

using namespace std;
using lint = long long;

inline char decode(int i) {
    return i + (i < 10 ? '0' : 'A' - 10);
}

bool solve() {
    int N, M, Q;
    cin >> N >> M >> Q;
    if (N == 0) return false;

    vector<lint> pos(M, (1LL << N) - 1);
    lint light = 0;

    for (int q = 0; q < Q; ++q) {
        string S;
        cin >> S;
        for (int i = 0; i < N; ++i) {
            if (S[i] == '1') light ^= (1LL << i);
        }

        string B;
        cin >> B;
        for (int i = 0; i < M; ++i) {
            if (B[i] == '0') {
                pos[i] &= (~light & ((1LL << N) - 1));
            } else {
                pos[i] &= light;
            }
        }
    }

    for (auto pat : pos) {
        vector<int> ans;
        for (int i = 0; i < N; ++i) {
            if ((pat >> i) & 1) ans.push_back(i);
        }
        if (ans.size() > 1) {
            cout << '?';
        } else {
            cout << decode(ans[0]);
        }
    }
    cout << endl;
    return true;
}

int main() {
    while (solve()) {}
    return 0;
}

