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