#include <iostream>
#include <string>
using namespace std;

int main()
{ 
  int N,M,s,c;
  bool x = true;
  cin >> N >> M;
  int value[N] = {-1};
  for(int i = 0; i < N;i++){
    value[i] = -1;
  }
  int v = 0;
  for(int i = 0; i < M;i++){
    cin >> s >> c;
    if(value[s-1] != -1 && value[s-1] != c){
      x = false;

    }
    else value[s-1] = c;
  }

  if(value[0] == 0) x = false;
  else{
    for(int i = 0; i < N;i++){
      if(i == 0 && value[0] == -1) value[0] = 1;
      else if(value[i] == -1) value[i] = 0;
    }
  }
  for(int i = 0; i < N;i++){
    v = 10 * v + value[i];
  }
 // if(!x) cout << -1 << endl;
 cout << v << endl;
  return 0;
}