#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> r(N);
  for (int i = 0; i < N; i++) r.at(i) = -1;
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    s = s - 1;
    if (r.at(s) == -1 || r.at(s) == c) {
      r.at(s) = c;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  if (r.at(0) == 0) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < N; i++) {
    if (i == N - 1) {
      if (r.at(i) == -1) {
        if (N == 1) {
          r.at(i) = 0;
        } else {
          r.at(i) = 1;
        }
      }
    } else {
      if (r.at(i) == -1) r.at(i) = 0;
    }
    cout << r.at(i);
  }
  cout << endl;
}
