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