#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> I(N, -1);
  bool ok = true;
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (I[s] != -1 and I[s] != c) {
      ok = false;
    }
    I[s] = c;
  }
  if (N > 1 and I[0] == 0) {
    ok = false;
  }
  if (ok) {
    for (int i = 0; i < N; i++) {
      if (I[i] == -1) {
        if (i == 0) {
          cout << 1;
        } else {
          cout << 0;
        }
      } else {
        cout << I[i];
      }
    }
    cout << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
