#include<bits/stdc++.h>
#define ll long long int
#include <iostream>
using namespace std;

int main() {
   ll n,m;cin>>n>>m;int x=0;
   ll a[n]={0};
 
  while(m--){
       ll s,c;
       cin>>s>>c;
       if(s==1&&c==0) {x=-1;}
       if(x==0){
           for(int i=0;i<n;i++){
               if(a[s-1]!=0&&a[s-1]!=c){x=-1;break;}
               else a[s-1]=c;
           }
       }
       
   }
   if(x==-1) {cout<<x;return 0;}
   if(a[0]==0&&n!=1) {cout<<1;for(int i=1;i<n;i++) cout<<a[i];return 0;}
   for(int i=0;i<n;i++) cout<<a[i];
   
  return 0;
}
