#include <bits/stdc++.h>
int check[4];
int main(void) {
  int n, m, s, c, i, arr[4], flag = 0;
  scanf("%d %d", &n, &m);
  if (m == 0) flag = 1;
  for (i = 0; i < m; i++) {
    scanf("%d %d", &s, &c);
    if (s == 1 && c == 0 && n != 1) flag = 1;
    if (check[s] == 0) {
      arr[s] = c;
      check[s] = 1;
    }
    if (check[s] == 1 && arr[s] != c) {
      flag = 1;
    }
  }
  if (flag == 1)
    printf("-1");
  else {
    if (check[1] == 0) arr[1] = 1;
    printf("%d", arr[1]);
    for (i = 2; i <= n; i++) {
      if (check[i] == 0) arr[i] = 0;
      printf("%d", arr[i]);
    }
  }
  return 0;
}
