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