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