#include <bits/stdc++.h>
int main() {
  size_t n, m;
  std::cin >> n >> m;
  std::vector<std::pair<size_t, char>> v(m);
  for (size_t i = 0; i < m; i++) {
    size_t s;
    char c;
    std::cin >> s >> c;
    v.at(i) = {s - 1, c};
  }
  size_t min = std::numeric_limits<size_t>::max();
  for (size_t i = std::pow(10, n - 1); i < std::pow(10, n); i++) {
    auto tmp = std::to_string(i);
    bool flag = true;
    for (const auto& e : v) {
      if (tmp.at(e.first) != e.second) {
        flag = false;
      }
    }
    if (flag) {
      min = std::min(min, i);
    }
  }
  if (min == std::numeric_limits<size_t>::max()) {
    std::cout << -1 << std::endl;
  } else {
    std::cout << min << std::endl;
  }
  return 0;
}
