#include <bits/stdc++.h>
#include<vector>
using namespace std;
  vector<vector<bool>>c(3,vector<bool>(3));
int main() {
    int n,b,c,d;
  cin>>n>>b;
  map<int,int>a;
  for(int i=0;i<3;i++){
      cin>>c>>d;
    if(a.count(c));
    else a.at(1)=1;
      if(a.at(c)==d);
      else{
      cout<<"-1";
      return 0;
      }
    }
    a[c]=d;
  }
  if(a.count(1));
  if(a.at(1)==0){
    cout<<"-1";
    return 0;
  }
  else {
    cout<<"-1";
    return 0;
  }
  for(int i=1;i<=n;i++){
    cout<<a[i];
  }
}