#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int m;
  cin >> m;
  vector<int> vec(n);
  vec.at(0) = 1;
  int a = 0;
  for (int i = 0; i < m; i++) {
    int t;
    int r;
    cin >> t >> r;
    if (vec.at(t - 1) > 100 && vec.at(t - 1) % 100 != r) {
      a = 1;
    } else {
      vec.at(t - 1) = 100 + r;
    }
  }
  if (vec.at(0) <= 50 && vec.size() == 1) {
    cout << 0 << endl;
  } else if (vec.at(0) % 100 == 0) {
    cout << -1 << endl;
  } else if (a == 1) {
    cout << -1 << endl;
  } else {
    for (int i = 0; i < n; i++) {
      cout << vec.at(i) % 100;
    }
    cout << endl;
  }
}
