#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> seq(N, 0);
  seq.at(0) = 1;
  vector<int> position(M);
  vector<int> change(M);
  for (int i = 0; i < int(M); i++) {
    cin >> position.at(i) >> change.at(i);
  }
  int non = 0;
  for (int i = 0; i < int(M); i++) {
    for (int j = 0; j < int(M); j++) {
      if (position.at(i) == position.at(j) && change.at(i) != change.at(j)) {
        non++;
      }
    }
  }
  if (position.at(0) == 1 && change.at(0) == 0) {
    if (N > 1) non++;
  }
  for (int i = 0; i < int(M); i++) {
    seq.at(position.at(i) - 1) = change.at(i);
  }
  if (non > 0)
    cout << -1 << endl;
  else {
    for (int i = 0; i < int(N); i++) {
      cout << seq.at(i);
    }
    cout << endl;
  }
}
