#include <bits/stdc++.h>
int main() {
  int i, j, k;
  long long int l = 0;
  int m, g = 0, n, q;
  int f = 0;
  int s[110], c[110], a[6] = {11, 11, 11, 11, 11, 11};
  scanf("%d %d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%d %d", &s[i], &c[i]);
    if (s[i] == 1) {
      if (c[i] == 0) {
        if (n == 1) {
          f = 0;
        } else {
          f = 1;
        }
      }
    }
    if (a[s[i] - 1] != 11) {
      if (a[s[i] - 1] != c[i]) {
        f = 1;
      }
    } else {
      a[s[i] - 1] = c[i];
    }
  }
  if (a[0] == 11) {
    a[0] = 1;
  }
  for (i = n; i > 0; i--) {
    if (a[i] == 11) {
      a[i] = 0;
    }
  }
  if (f == 1) {
    printf("-1");
    return 0;
  }
  for (i = 0; i < n; i++) {
    printf("%d", a[i]);
  }
  return 0;
}
