#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<functional>
#include<algorithm>
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;



int bits_ctzll(unsigned long long b){
	b&=-b;
	int res=0;
	for(int i=5;i>=0;i--){
		int shift=1<<i;
		if(b>>shift){
			b>>=shift;
			res|=shift;
		}
	}
	return res;
}


int main(){
	int n,m,q;
	long long maybe[1000];

	while(cin>>n>>m>>q,n|m|q){
		fill_n(maybe,m,(1LL<<n)-1);
		long long switches=0;
		rep(i,q){
			long long s=0;
			string str,b;
			cin>>str;
			rep(i,n)s|=(long long)(str[i]-'0')<<i;
			cin>>b;
			switches^=s;
			rep(i,m){
				if(b[i]=='1'){
					maybe[i]&=switches;
				}else{
					maybe[i]&=~switches;
				}
			}
		}
		rep(i,m){
			if(maybe[i]&maybe[i]-1){
				cout<<'?';
			}else{
				int ctz=bits_ctzll(maybe[i]);
				if(ctz<10)cout<<ctz;
				else cout<<char('A'+ctz-10);
			}
		}
		cout<<endl;
	}
	return 0;
}