#include <bits/stdc++.h>
int main() {
  size_t n, m;
  std::cin >> n >> m;
  std::map<size_t, size_t> map;
  for (size_t i = 0; i < m; i++) {
    size_t s, c;
    std::cin >> s >> c;
    auto p = map.emplace(s, c);
    if ((*p.first).second != c) {
      std::cout << -1 << std::endl;
      return 0;
    }
  }
  std::string ans;
  for (const auto& e : map) {
    size_t s, c;
    std::tie(s, c) = e;
    std::cout << s << ' ' << c << std::endl;
    if (ans.size() + 1 < s) {
      for (size_t i = ans.size() + 1; i < s; i++) {
        ans += '0';
      }
      ans += std::to_string(c);
    } else {
      ans += std::to_string(c);
    }
  }
  if (ans.size() == n) {
    std::cout << ans << std::endl;
  } else {
    std::cout << -1 << std::endl;
  }
  return 0;
}
