#include <iostream>
#include <stdio.h>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
 
#define rep(i,n) for(int i = 0; i < n; i++)
 
typedef long long ll;
 
using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;
 
int main(){
  int N,M;
  cin >> N >> M;
  vector<pair<int,int> > vp(M);
  rep(i,M) cin >> vp[i].first >> vp[i].second;
  sort(vp.begin(), vp.end());

  bool same = false;
  if(M==0 && N==1){
    cout << 0 << endl;
    break;
  }
  else if(M==0 && N==2){
    cout << 10 << endl;
    break;
  }
  else if(M==0 && N==3){
    cout << 100 << endl;
    break;
  }
  rep(i,M){
    if(i!=0 && vp[i-1].first==vp[i].first) same = true;
    else same = false;
    if((vp[i].first==1 && vp[i].second==0) || \
       (same && vp[i-1].second!=vp[i].second)){
      cout << -1 << endl;
      return 0;
    }    
  }
  string ans = "";
  rep(i,N){
    bool done;
    rep(j,M){
      if(i==(vp[j].first-1)){
	ans+=to_string(vp[j].second);
	done = true;
	break;
      }
      else done=false;
    }
    if(i==0 && !done) ans+="1";
    else if(!done) ans+="0";
  }
  cout << ans << endl;
}
