#include <bits/stdc++.h>
using ll = long long;
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  vector<int> v(N, -1);
  for (ll i = 0; i < ll(M); i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (v.at(s) == -1 || v.at(s) == c)
      v.at(s) = c;
    else {
      cout << -1 << endl;
      return 0;
    }
  }
  bool zero = true;
  for (ll i = 0; i < ll(N); i++) {
    if (i == 0 && v.at(i) == 0) {
      cout << -1 << endl;
      break;
    } else if (zero && v.at(i) == -1)
      cout << 1;
    else if (!zero && v.at(i) == -1) {
      cout << 0;
      zero = false;
    } else {
      cout << v.at(i);
      zero = false;
    }
  }
  cout << "\n";
  return 0;
}
