#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  int si, ci;
  bool dup, topz = false;
  cin >> N >> M;
  vector<int> vec(N, -1);
  for (int i = 0; i < M; i++) {
    cin >> si >> ci;
    if (vec[si - 1] == -1) {
      vec[si - 1] = ci;
    } else {
      if (vec[si - 1] != ci) {
        cout << "vec" << vec[si - 1] << endl;
        cout << "ci" << ci << endl;
        cout << -1 << endl;
        return 0;
      }
    }
  }
  if (vec[0] == 0) {
    if (N == 1) {
      cout << 0 << endl;
      return 0;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i = 0; i < N; i++) {
    if (vec[i] == -1) {
      if (i == 0) {
        vec[i] = (N == 1) ? 0 : 1;
      } else {
        vec[i] = 0;
      }
    }
    cout << vec[i];
  }
  cout << endl;
}
