#include<bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); i++)
#define ll long long
using namespace std;

int main() {
  int n,m; cin>>n>>m;
  vector<int> a(n,-1);
  bool frag=true;
  rep(i, m) {
    int s,c; cin>>s>>c;
    if (a[s-1]!=-1&&a[s-1]!=c) frag=false;
    a[s-1]=c;
  }
  if (n!=1&&a[0]==0) frag=false;
  if (!frag) cout<<-1<<endl;
  if (n==1) cout<<max(0, a[0])<<endl;
  else {
    rep(i, n) {
    if (i==0) cout<<max(1, a[i]);
    else {
      if (a[i]==-1) cout<<0;
      else cout<<a[i];
    }
    cout<<endl;
  }
}
