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