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