#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int N, M;
  cin >> N >> M;
  vector<int> S(N, -1);
  int s, t;
  bool bad = false;
  for (int i = 0; i < M; i++) {
    cin >> s >> t;
    if (S.at(s - 1) != -1) {
      if (S.at(s - 1) != t) {
        bad = true;
      }
    }
    S.at(s - 1) = t;
  }
  if (bad) {
    cout << -1 << endl;
    return 0;
  } else {
    if (S.at(0) == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (S.at(0) == -1) {
      S.at(0) = 1;
    }
    for (int i = 1; i < N; i++) {
      if (S.at(s) == -1) {
        S.at(s) = 0;
      }
    }
    for (int i = 0; i < N; i++) {
      cout << S.at(i);
    }
    cout << endl;
  }
  return 0;
}
