#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> v(N + 1, -1);
  for (auto x = (0); (x) < (M); ++(x)) {
    long long s, c;
    cin >> s >> c;
    if (v.at(s) == -1) {
      v.at(s) = c;
    } else if (v.at(s) != c) {
      cout << -1 << endl;
      cerr << "RUN: until " << (30) << "th line." << endl;
      return 0;
    }
  }
  if (N != 1 && v.at(1) == 0) {
    cerr << "RUN: until " << (36) << "th line." << endl;
    cerr << "[";
    for (auto itr = v.begin(); itr != v.end(); ++itr) {
      cerr << *itr << (itr != --v.end() ? ", " : "");
    }
    cerr << "]" << endl;
    cout << -1 << endl;
    return 0;
  }
  for (auto i = (1); (i) < ((long long)v.size()); ++(i)) {
    if (i == 1) {
      if (v.at(i) == -1) v.at(i) = 1;
    } else if (v.at(i) == -1) {
      v.at(i) = 0;
    }
  }
  for (auto i = (1); (i) < ((long long)v.size()); ++(i)) {
    cout << v.at(i);
  }
  cout << endl;
}
