#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define forI(n) for(ll i = 0 ; i<n ; i++) 
#define forD(an) for(ll i = n-1 ; i>=0 ; i--)
#define MOD 1000000007

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n,m; cin>>n>>m;
  	ll a[n]={};
  	while(m--) {
  		ll s,c; cin>>s>>c;
      if(a[s-1]==0)
   		 a[s-1]=c;
  }
  if(n==1) cout << a[0] ;
  else if(a[0]==0) cout <<"-1";
  else {
  	ll s=0; 
    for(ll i=0;i<n;++i) {
    	s = s*10 + a[i];
    }
    cout << s ;
  }
  return 0;
}