#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  int B = 0;
  cin >> N >> M;
  vector<int> vec(3);
  vec = {0, 0, 0};
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    if (vec.at(a - 1) == 0) {
      vec.at(a - 1) = b;
    } else if (vec.at(a - 1) != b || vec.at(0) == 0) {
      cout << "-1" << endl;
      B = 10;
      break;
    }
  }
  if (vec.at(0) == 0) {
    vec.at(0) = 1;
  }
  if (B == 0) {
    for (int i = 0; i < N; i++) {
      cout << vec.at(i);
    }
  }
}
