#include <bits/stdc++.h>
int main(void) {
  int i, j, k;
  int *number;
  int *digits;
  int N, M;
  int s, c;
  scanf("%d %d", &N, &M);
  number = new int[N];
  digits = new int[N];
  for (i = 0; i < N; i++) {
    digits[i] = 0;
    number[i] = 0;
  }
  for (i = 0; i < M; i++) {
    int s, c;
    scanf("%d %d", &s, &c);
    digits[s - 1] = 1;
    number[s - 1] = c;
  }
  if (N != 1 && number[0] == 0) {
    puts("-1");
  } else {
    for (i = 0; i < N; i++) printf("%d", number[i]);
    puts("");
  }
  return 0;
}
