#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, s, c;
  char ss[10];
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (int)(10); i++) ss[i] = -1;
  for (int i = 0; i < (int)(m); i++) {
    scanf("%d%d", &s, &c);
    if (!(ss[n - s] == -1 || ss[n - s] == c) || s >= n) {
      printf("-1\n");
      return 0;
    }
    ss[n - s] = c;
  }
  if (ss[n - 1] == 0 && n > 1) {
    printf("-1\n");
    return 0;
  }
  for (int i = n - 1; i >= 0; i--) {
    if (i == n - 1 && ss[i] == -1)
      printf("1");
    else if (ss[i] == -1)
      printf("0");
    else
      printf("%d", ss[i]);
  }
  printf("\n");
  return 0;
}
