#include <bits/stdc++.h>
int main() {
  long long n, m;
  std::cin >> n >> m;
  std::vector<long long> v(n, -1);
  for (size_t i = 0; i < m; i++) {
    long long a, b;
    std::cin >> a >> b;
    if (v[a - 1] == -1 || v[a - 1] == b) {
      v[a - 1] = b;
    } else {
      std::cout << -1 << std::endl;
      return 0;
    }
  }
  if (v[0] == 0) {
    std::cout << -1 << std::endl;
    return 0;
  }
  if (n > 1) v[0] = std::max(v[0], 1LL);
  for (size_t i = 0; i < n; i++) {
    std::cout << std::max(v[i], 0LL);
  }
  std::cout << std::endl;
  return 0;
}
