#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<long long> s(m), c(m);
  vector<long long> x(n, -1);
  for (int(i) = 0; (i) < (m); (i)++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (x[s] == -1 || x[s] == c) {
      x[s] = c;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int(i) = 0; (i) < (n); (i)++) {
    if (n > 1 && x[0] == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (x[i] == -1) {
      if (i == 0) {
        x[i] = 1;
      } else {
        x[i] = 0;
      }
    }
  }
  for (int(i) = 0; (i) < (n); (i)++) {
    cout << x[i];
  }
  cout << endl;
  return 0;
}
