#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  int S[10], C[10];
  cin >> N >> M;
  int tmp[N];
  for (int i = 0; i < N; i++) {
    tmp[i] = -100;
  }
  for (int i = 0; i < M; i++) {
    cin >> S[i] >> C[i];
  }
  for (int i = 0; i < M; i++) {
    if (S[i] == 1 && C[i] == 0) {
      printf("-1");
      return 0;
    }
    if (tmp[S[i] - 1] < 0) {
      tmp[S[i] - 1] = C[i];
    } else if (tmp[S[i] - 1] != C[i]) {
      printf("-1");
      return 0;
    }
  }
  for (int i = 0; i < N - 1; i++) {
    if (tmp[i] < 0) {
      tmp[i] = 0;
    }
  }
  if (tmp[N] < 0) {
    tmp[N] = 1;
  }
  for (int i = 0; i < N; i++) {
    printf("%d", tmp[i]);
  }
  return 0;
}
