#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
int main(){
	while(true){
		int N,M,Q;
		cin>>N>>M>>Q;
		if(N==0) break;
		bool a[36]={},no[1000][36]={};
		rep(i,Q){
			string s,b;
			cin>>s>>b;
			rep(j,N) if(s[j]=='1') a[j]=!a[j];
			rep(j,M) rep(k,N) if(b[j]=='1'^a[k]) no[j][k]=1;
		}
		rep(i,M){
			int x=-1;
			rep(j,N) if(!no[i][j]){
				if(x==-1) x=j;
				else x=-2;
			}
			if(x>=0){
				if(x<10) printf("%c",'0'+x);
				else printf("%c",'A'+x-10);
			}else{
				cout<<'?';
			}
		}
		cout<<endl;
	}
}