#include <bits/stdc++.h>
using namespace std;
signed main() {
  int n, m, ket[3], s, c;
  bool f = true;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    ket[i] = -1;
  }
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    if (ket[s - 1] != c && ket[s - 1] != -1) {
      f = false;
    } else {
      ket[s - 1] = c;
    }
  }
  if (ket[0] == 0 && n > 1) {
    f = false;
  }
  if (f) {
    cout << max(ket[0], 1);
    for (int i = 1; i < n; i++) {
      cout << max(ket[i], 0);
    }
  } else {
    cout << "-1";
  }
  cout << endl;
  return (0);
}
