#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<int> ans(n,0);
  (n==1?ans.at(0)=0:ans.at(0)=1);
  vector<int> check(n,-1);
  rep(i,m){
    int s,c;
    cin>>s>>c;
    s--;
    if((check.at(s)>0&&c!=ans.at(s))||(s==0&&c==0&&n!=1)){
      cout<<-1;
      return 0;
    }
    else{
      check.at(s)*=-1;
      ans.at(s)=c;
    }
  }
  rep(i,n) cout<<ans.at(i);
}
