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