#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ss(m), cs(m);
  for (int i = 0; i < m; i++) {
    cin >> ss[i] >> cs[i];
    ss[i]--;
  }
  auto pow_orig = [](int a, int n) {
    int r = 1;
    for (; n; n >>= 1) {
      if (n & 1) {
        r *= a;
      }
      a *= a;
    }
    return r;
  };
  for (int x = pow_orig(10, n - 1); x < pow_orig(10, n); x++) {
    string s = to_string(x);
    if (s.size() != n) {
      continue;
    }
    bool f = true;
    for (int i = 0; i < m; i++) {
      f &= (s[ss[i]] == ('0' + cs[i]));
    }
    if (f) {
      cout << s << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
