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