#include <bits/stdc++.h>
int main(void) {
  int n, m;
  int s[5], c[5];
  int count = 0;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) scanf("%d %d", &s[i], &c[i]);
  for (int i = (int)pow(10, n - 1); i < (int)pow(10, n); i++) {
    count = 1;
    for (int j = 0; j < m; j++) {
      if ((i % (int)pow(10, n - s[j] + 1)) / (int)pow(10, n - s[j]) == c[j])
        count *= 1;
      else
        count *= 0;
    }
    if (count == 1) {
      printf("%d", i);
      return 0;
    }
  }
  printf("%d", -1);
  return 0;
}
