#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<tuple<int, int>> a;
  for (int i = 0; i < m; i++) {
    int ss, cc;
    cin >> ss >> cc;
    a.emplace_back(tie(ss, cc));
  }
  int x = 1;
  if (n == 1) {
    for (tuple<int, int> t : a) {
      int ss, cc;
      tie(ss, cc) = t;
      if (cc != 0) x = 0;
    }
    if (x == 1) cout << 0 << endl;
    return 0;
  }
  for (int i = pow(10, n - 1); i < pow(10, n); i++) {
    x = 1;
    for (tuple<int, int> t : a) {
      int ss, cc;
      tie(ss, cc) = t;
      if ((int)((i % (int)pow(10, n - ss + 1)) / pow(10, n - ss)) != cc) x = 0;
    }
    if (x == 1) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
