#include <bits/stdc++.h>
int ans[5];
int N, M;
int request[10][2];
int main() {
  scanf("%d%d", &N, &M);
  ans[N] = 1;
  for (int i = 1; i <= M; i++) {
    int s, c;
    scanf("%d%d", &s, &c);
    request[i][0] = s;
    request[i][1] = c;
    ans[N + 1 - s] = c;
  }
  bool ok = (ans[N] != 0) || N == 1;
  for (int i = 1; i <= M; i++)
    ok = ok && (ans[N + 1 - request[i][0]] == request[i][1]);
  if (ok) {
    for (int i = N; i >= 1; i--) printf("%d", ans[i]);
    putchar('\n');
  } else
    puts("-1");
  return 0;
}
