#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define ld long double
#define ii pair<int,int>
#define ull unsigned long long
#define all(k) k.begin(),k.end()
#define rall(k) k.rbegin(),k.rend()
#define db(x) cerr<<#x<<" = "<<x<<endl
#define len(v) ((int)v.size())
#define endl '\n'



void solve(){
  int n,m;
  cin>>n>>m;
  vector<int> a(n,-1);
  vector<ii> regras;
  while(m--){
    int s,c;
    cin>>s>>c;
    regras.pb({s,c});
    a[s-1]=c;
  }

  for(auto &p : regras){
    if(a[p.x-1]!=p.y){
      cout<<-1<<endl;
      return;
    }
  }

  if(a[0]==-1) a[0]=1;
  for(int i=1;i<n;i++) if(v[i]==-1) v=0;

  if(a[0]==0 and n!=1){
    cout<<-1<<endl;
    return;
  }

  for(auto &v : a) cout<<v;
  cout<<endl;

}
int32_t main(){
  ios::sync_with_stdio(0); cin.tie(0);
  int t; 
#ifdef TESTCASE
  cin>>t;
#else 
  t = 1;
#endif
  while(t--) solve();
}
