#include <bits/stdc++.h>
char st[3];
int check[3];
int main(void) {
  int n, m;
  st[0] = '1';
  st[1] = '0';
  st[2] = '0';
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (check[a - 1] == 0) {
      check[a - 1] = 1;
      st[a - 1] = '0' + b;
    } else if (st[a - 1] == '0' + b) {
      continue;
    } else {
      printf("-1");
      return 0;
    }
  }
  int t = 1;
  for (int i = 1; i < n; i++) t = t * 10;
  if (atoi(st) < t)
    printf("-1");
  else
    printf("%s", st);
  return 0;
}
