#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 998244353;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

string solve(int N, int M, int Q) {
    vector<vector<int>> bulb_to_switch(M, vector<int>(N, 1));
    vector<int> ans(M);
    string ret;
    string S;
    for (int i = 0; i < N; i++) {
        S += '0';
    }
    for (int q = 0; q < Q; q++) {
        string s, B; cin >> s >> B;
        for (int i = 0; i < N; i++) {
            if (s[i] == '1') {
                if (S[i] == '1') S[i] = '0';
                else S[i] = '1';
            }
        }
        for (int i = 0; i < M; i++) {
            for (int j = 0; j < N; j++) {
                if (B[i] == '0' && S[j] == '1') {
                    bulb_to_switch[i][j] = 0;
                }
                if (B[i] == '1' && S[j] == '0') {
                    bulb_to_switch[i][j] = 0;
                }
            }
        }
    }
    for (int i = 0; i < M; i++) {
        int sw = 100;
        for (int j = 0; j < N; j++) {
            if (bulb_to_switch[i][j] == 1) {
                if (sw == 100) sw = j;
                else {
                    sw = 100;
                    break;
                }
            }
        }
        ans[i] = sw;
    }
    for (int i = 0; i < M; i++) {
        if (ans[i] == 100) ret += '?';
        else if (ans[i] <= 9) ret += '0' + ans[i];
        else ret += 'A' + ans[i] - 10;
    }
    // for (int i = 0; i < M; i++) {
    //     for (int j = 0; j < N; j++) {
    //         cout << bulb_to_switch[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    return ret;
}

int main(void) {
    int N, M, Q;
    vector<string> ans;
    while (1) {
        cin >> N >> M >> Q;
        if (N == 0) break;
        ans.push_back(solve(N, M, Q));        
    }
    for (auto i : ans){
        cout << i << endl;
    }
}



