#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  map<int, int> A;
  for (int i = 0; i < M; i++) {
    int B, C;
    cin >> B >> C;
    if (A.count(B) && A[B] != C) {
      cout << -1 << endl;
      return 0;
    }
    A[B] = C;
  }
  string T = "";
  if (A.count(1)) {
    int B = A[1];
    char C = B + '0';
    T.push_back(C);
  } else {
    T.push_back('1');
  }
  for (int i = 0; i < N - 1; i++) {
    if (A.count(i + 2)) {
      int B = A[i + 2];
      char C = B + '0';
      T.push_back(C);
    } else {
      T.push_back('0');
    }
  }
  cout << T << endl;
}
