#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  bool exist = true;
  map<int, int> sc;
  int x = pow(10, n - 1);
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    auto itr = sc.find(s);
    if (s == 1 && c == 0) {
      exist = false;
    } else if (itr != sc.end() && itr->second != c) {
      exist = false;
    }
    if (itr == sc.end()) {
      sc.insert(make_pair(s, c));
      x += c * (pow(10, n - s));
      if (s == n) {
        x -= pow(10, n - 1);
      }
    }
  }
  if (x < pow(10, n - 1)) {
    x += pow(10, n - 1);
  }
  if (exist) {
    cout << x << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
