#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> M;
  bool ok = true;
  while (m--) {
    int s, d;
    cin >> s >> d;
    s--;
    if (s >= n) {
      ok = false;
    }
    if (s == 0 && n != 1 && d == 0) {
      ok = false;
    }
    if (M.count(s) == 0) {
      M[s] = d;
    } else {
      if (M[s] != d) ok = false;
    }
  }
  if (!ok)
    cout << -1;
  else
    for (int s = 0; s < n; s++) {
      if (M.count(s) == 1)
        cout << M[s];
      else if (s == 0)
        cout << 1;
      else
        cout << 0;
    }
  cout << '\n';
  return 0;
}
