#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
int main() {
  lint n, m;
  cin >> n >> m;
  vector<lint> v(n, -1);
  for (int i = (0), i_end_ = (m); i < i_end_; i++) {
    lint s, c;
    cin >> s >> c;
    if (v[s - 1] != -1 && v[s - 1] != c) {
      cout << -1 << "\n";
      return 0;
    }
    v[s - 1] = c;
  }
  if (v[0] == 0) {
    cout << -1 << "\n";
    return 0;
  } else if (v[0] == -1) {
    cout << 1;
  } else {
    cout << v[0];
  }
  for (int i = (1), i_end_ = (n); i < i_end_; i++) {
    if (v[i] == -1) {
      cout << 0;
    } else {
      cout << v[i];
    }
  }
  cout << "\n";
  return 0;
}
