#include <bits/stdc++.h>
int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> num(n, -1);
  for (int i = 0; i < m; i++) {
    int s, c;
    std::cin >> s >> c;
    if (num[s - 1] == -1 || num[s - 1] == c) {
      num[s - 1] = c;
    } else {
      num[0] = 0;
      break;
    }
  }
  if (num[0] == 0) {
    std::cout << -1 << std::endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (num[i] == -1) {
      if (i == 0)
        num[i] = 1;
      else
        num[i] = 0;
    }
    printf("%d", num[i]);
  }
  printf("\n");
  return 0;
}
