#include <cstdio> 
#include <cstdlib> 
#include <numeric>
#include <cmath> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <cassert>
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
using namespace std; 
#define REP(i,b,n) for(int i=b;i<n;i++) 
#define rep(i,n)      REP(i,0,n) 
#define pb push_back  
#define mp make_pair 
#define ALL(C)   (C).begin(),(C).end() 
template<class T> void vp(T &a,int p){rep(i,p)cout << a[i]<<" ";cout << endl;}  

typedef complex<double>P; 
typedef long long ll; 
typedef unsigned long long ull; 
typedef pair<int,int> pii; 
typedef vector<int> vint;

vector<vint> gene(int n){
  vector<vint> ret;
  vector<int> tmp(n);
  rep(i,n)tmp[i]=i+1;
  rep(i,n/2){
    rep(j,n/2){
      int ii=rand()%n,jj=rand()%n;
      swap(tmp[ii],tmp[jj]);
    }
    vector<int> ins(tmp.begin(),tmp.begin()+n/2);
    sort(ALL(ins));
    ret.push_back(ins);
  }
  return ret;
}

void output(vector<vint> &a){
  cout <<"case " << endl;
  rep(i,(int)a.size())vp(a[i],a[i].size());
}

void solve2(int n,vector<vint> & in){
  vector<int> val(in.size(),0);
  vector<int> cnt(n,0);
  string tmp(n,'0');
  priority_queue<pii,vector<pii>,greater<pii> >Q;
  rep(i,in.size()){
    rep(j,(int)in[i].size())cnt[in[i][j]-1]++;
  }
  rep(i,n)Q.push(mp(cnt[i],i));
  while(!Q.empty()){
    int num=Q.top().second;Q.pop();
    bool dame=false,req=false;
    rep(i,in.size()){
      bool res=binary_search(ALL(in[i]),num);
      if (!res)continue;
      if (val[i] < n/8)req=true;
      if (3*n/8 == val[i])dame=true;
    }
    if (dame)continue;
    if (req){
      tmp[num-1]='1';
      rep(i,in.size()){
	if (binary_search(ALL(in[i]),num))val[i]++;
      }
    }
  }

  cout << tmp << endl;
#ifdef CHECK
  rep(i,in.size()){
    val[i]=0;
    rep(j,in[i].size())if (tmp[in[i][j]-1] == '1')val[i]++;
    assert(n/8 <= val[i] && val[i] <= 3*n/8);
  }
#endif
}


void solve(int n,vector<vint> &in){
  vector<int> p(in.size(),0);
  vector<int> val(in.size(),0);
  vector<int> a;
  REP(i,1,n+1){
    bool isok=true;
    rep(j,(int)in.size()){
      int &tp=p[j];
      if (tp == (int)in[j].size())continue;
      if (in[j][tp] != i)continue;
      if (val[j] == 3*n/8){isok=true;break;}
      if (val[j] < n/8){isok=false;}
    }
    if (!isok)a.push_back(i);
    rep(j,in.size()){
      int &tp=p[j];
      if (tp == (int)in[j].size())continue;
      if (in[j][tp] != i)continue;
      tp++;
      if (!isok)val[j]++;
    }
    if (!isok)a.push_back(i);
  }
  string tmp(n,'0');
  rep(i,a.size())tmp[a[i]]='1';
  cout << tmp << endl;
  rep(i,in.size()){
    val[i]=0;
    rep(j,in[i].size())if (tmp[in[i][j]-1] == '1')val[i]++;
    assert(n/8 <= val[i] && val[i] <= 3*n/8);
  }
}

main(){
#ifdef CHECK
  const int N = 8;
  rep(i,10000){
    vector<vint> tmp=gene(N);
    //output(tmp);
    //solve(N,tmp);
    solve2(N,tmp);
  }
#endif
  int n,k;
  while(cin>>n>>k && n){
    vector<vint> a;
    rep(i,k){
      vint b(n/2);
      rep(j,n/2)cin>>b[j];
      a.push_back(b);
    }
    solve2(n,a);
  }
  return false;
}

Measured memory_bytes: 1908