/*
This code was automatically submitted by chhongzh's bot!
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m;
char w[3005][3005],x[3005],y[3005];
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
x[i]=123;
y[i]=96;
for(int j=1;j<=m;j++){
cin>>w[i][j];
x[i]=min(x[i],w[i][j]);
y[i]=max(y[i],w[i][j]);
}
// cout<<x[i]<<" "<<y[i]<<endl;
}
for(int i=1;i<=n;i++){
bool ok=1;
for(int j=1;j<=n;j++){
if(i!=j&&x[i]>=y[j]){
ok=0;
}
}
cout<<ok;
}
return 0;
}