#include <iostream>
#include <string>
 
#define N 36
#define M 1000
 
using  namespace std;
 
void detect_wrong(bool is_candidate[N][M], bool switch_is_on[N], bool bulb_is_on[M], int n, int m) {
  for (int i=0; i<m; i++) {
    if (bulb_is_on[i]) {
      continue;
    }
    for (int j=0; j<n; j++) {
      if (switch_is_on[j]) {
        is_candidate[j][i] = false;
      }
    }
  }
  for (int i=0; i<n; i++) {
    if (switch_is_on[i]) {
      continue;
    }
    for (int j=0; j<m; j++) {
      if (bulb_is_on[j]) {
        is_candidate[i][j] = false;
      }
    }
  }
}
 
void print_result(bool is_candidate[N][M], int n, int m) {
  for (int i=0; i<m; i++) {
    bool is_multiple = false;
    int switch_num = -1;
    for (int j=0; j<n; j++) {
      if (is_candidate[j][i]) {
        if (switch_num < 0) {
          switch_num = j;
        }
        else {
          is_multiple = true;
        }
      }
    }
    if (is_multiple) {
      cout << '?';
    }
    else if (switch_num < 0) {
      cout << '?';
    }
    else if (switch_num < 10) {
      cout << (char)(switch_num+'0');
    }
    else {
      cout << (char)(switch_num+'A'-10);
    }
  }
  cout << endl;
}
 
int main() {
  int n, m, q;
  string s, b;
  bool switch_is_on[N], bulb_is_on[M];
  bool is_candidate[N][M];
  while (true) {
    cin >> n >> m >> q;
    if (n == 0) {
      return 0;
    }
    for (int i=0; i<n; i++) {
      switch_is_on[i] = false;
      for (int j=0; j<m; j++) {
        is_candidate[i][j] = true;
      }
    }
    for (int i=0; i<m; i++) {
      bulb_is_on[i] = false;
    }
    for (int i=0; i<q; i++) {
      cin >> s >> b;
      for (int j=0; j<n; j++) {
        if (s[j] == '1') {
          switch_is_on[j] = !switch_is_on[j];
        }
      }
      for (int j=0; j<m; j++) {
        if (b[j] == '1') {
          bulb_is_on[j] = true;
        }
        else {
          bulb_is_on[j] = false;
        }
      }
      detect_wrong(is_candidate, switch_is_on, bulb_is_on, n, m);
    }
    print_result(is_candidate, n, m);
  }
}
 