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