#include <iostream>
#include <fstream>
#include <math.h>
#include <string>
#include <iomanip>

using namespace std;

int main(){

  int n, m;
  cin >> n >> m;

  int s[m], c[m];
  int number = 0, tmp[n] = {};
  for (int i=0; i<m; i++){
    cin >> s[i] >> c[i];
    tmp[n-s[i]] = c[i];
  }

  for (int i=0; i<n; i++){
    number += pow(10,i) * tmp[i];
  }

  if(tmp[n-1] == 0) {
    cout << -1;
  } else {
    cout << number;
  }

}
