#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main() {

  while( true ) {

    long long int n, m, q;
    cin >> n >> m >> q;
    if ( n == 0 ) break;

    string k = "0";
    for ( long long int i = 0; i < q; i++ ) {
      k += "0";
    }

    vector< string > s;
    for ( long long int i = 0; i < n; i++ ) {
      s.push_back( k );
    }

    vector< string > b;
    for ( long long int i = 0; i < m; i++ ) {
      b.push_back( k );
    }

    for ( long long int i = 0; i < q; i++ ) {

      string in_s, in_b;
      cin >> in_s >> in_b;

      for ( long long int j = 0; j < n; j++ ) {
	s[j][i+1] = '0' + ( s[j][i] - '0' ) ^ ( in_s[j] - '0' );
      }

      for ( long long int j = 0; j < m; j++ ) {
	b[j][i+1] = in_b[j];
      }

    }

    for ( long long int i = 0; i < m; i++ ) {

      long long int ans = -1;

      for ( long long int j = 0; j < n; j++ ) {

	if ( s[j] == b[i] ) {
	  if ( ans == -1 ) {
	    ans = j;
	  }else {
	    ans = -1;
	    break;
	  }
	}

      }

      char c;
      if ( ans == -1 ) {
	c = '?';
      }else {
	if ( ans <= 9 ) {
	  c = ans + '0';
	}else {
	  c = ( ans - 10 ) + 'A';
	}
      }
      cout << c;

    }

    cout << endl;

  }

  return 0;

}