#include <bits/stdc++.h>
int main() {
  int N, M;
  scanf("%d %d", &N, &M);
  int s;
  int c;
  int count[M];
  int info[M];
  int worth = 0;
  for (int i = 0; i < M; ++i) {
    info[i] = 0;
    count[i] = 0;
  }
  if (N > 1) {
    info[0] = 1;
  }
  for (int j = 0; j < M; ++j) {
    scanf("%d %d", &s, &c);
    if (info[s - 1] == c && count[s - 1] >= 1) {
    } else if (s == 1 && c == 0) {
      worth = -1;
      count[0]++;
    } else if (count[s - 1] == 0) {
      info[s - 1] = c;
      count[s - 1]++;
    } else {
      worth = -1;
    }
  }
  if (worth == -1) {
    printf("-1");
  } else {
    for (int i = 0; i < M; ++i) {
      printf("%d", info[i]);
    }
  }
}
int A() {
  int N;
  scanf("%d", &N);
  printf("%d", N / 2 + N % 2);
  return 0;
}
int B() {
  int bingo[3][3];
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      scanf("%d", &bingo[i][j]);
    }
  }
  int N;
  scanf("%d", &N);
  int S[N];
  for (int i = 0; i < N; ++i) {
    scanf("%d", &S[i]);
    for (int j = 0; j < 3; ++j) {
      for (int k = 0; k < 3; ++k) {
        if (bingo[j][k] == S[i]) {
          bingo[j][k] = 0;
        }
      }
    }
  }
  if (bingo[0][0] == bingo[0][1] && bingo[0][1] == bingo[0][2]) {
    printf("Yes");
    return 0;
  } else if (bingo[1][0] == bingo[1][1] && bingo[1][1] == bingo[1][2]) {
    printf("Yes");
    return 0;
  } else if (bingo[2][0] == bingo[2][1] && bingo[2][1] == bingo[2][2]) {
    printf("Yes");
    return 0;
  } else if (bingo[0][0] == bingo[1][0] && bingo[1][0] == bingo[2][0]) {
    printf("Yes");
    return 0;
  } else if (bingo[0][1] == bingo[1][1] && bingo[1][1] == bingo[2][1]) {
    printf("Yes");
    return 0;
  } else if (bingo[0][2] == bingo[1][2] && bingo[1][2] == bingo[2][2]) {
    printf("Yes");
    return 0;
  } else if (bingo[0][0] == bingo[1][1] && bingo[1][1] == bingo[2][2]) {
    printf("Yes");
    return 0;
  } else if (bingo[0][2] == bingo[1][1] && bingo[1][1] == bingo[2][0]) {
    printf("Yes");
    return 0;
  } else {
    printf("No");
    return 0;
  }
}
