#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N,M;
  cin>>N>>M;
  int A[N] = {0};
  while(M--){
    int p,d;
    cin>>p>>d;
    A[p-1] = d;
  }
  if(A[0]==0){cout<<-1; return 0;}
  for(int i = 0; i<N; i++){
    cout<<A[i];
  }
  return 0;
}
  