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