#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using ld = long double;
using pii = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  vi num(n, -1);
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    if (s == 1 && c == 0 && n != 1) {
      cout << -1 << endl;
      return 0;
    }
    if (num.at(s - 1) == -1)
      num.at(s - 1) = c;
    else {
      if (num.at(s - 1) != c) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  if (n == 1)
    cout << num.at(0) << endl;
  else {
    if (num.at(0) == -1) num.at(0) = 1;
    for (int i = 0; i < n; i++) {
      if (num.at(i) == -1) num.at(i) = 0;
      cout << num.at(i);
    }
    cout << endl;
  }
}
