#include <bits/stdc++.h>
using namespace std;
void bad() {
  cout << "-1\n";
  exit(0);
}
const int maxn = 3e4 + 79, maxk = 2e2 + 79;
vector<vector<int> > d(maxk, vector<int>(maxn)), g(maxn), path(maxk), v(maxn);
vector<int> p(maxn, -1), mark(maxn, 0), s;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < n; j++) cin >> d[i][j];
    if (count(d[i].begin(), d[i].begin() + n, 0) != 1) bad();
    s.push_back(min_element(d[i].begin(), d[i].begin() + n) - d[i].begin());
    if (count(s.begin(), s.end(), s.back()) > 1) bad();
  }
  mark[s[0]] = true;
  path[0].push_back(s[0]);
  for (int i = 1; i < k; i++) {
    vector<pair<int, int> > tmppath;
    for (int j = 0; j < n; j++)
      if (d[0][j] + d[i][j] == d[0][s[i]]) tmppath.push_back({d[0][j], j});
    sort(tmppath.begin(), tmppath.end());
    if (d[0][s[i]] + 1 != tmppath.size()) bad();
    for (pair<int, int> j : tmppath) path[i].push_back(j.second);
    if (count(path[i].begin(), path[i].end(), -1)) bad();
    for (int j = 1; j < path[i].size(); j++) {
      if (d[0][path[i][j - 1]] + 1 != d[0][path[i][j]] ||
          (p[path[i][j]] != -1 && p[path[i][j]] != path[i][j - 1]))
        bad();
      p[path[i][j]] = path[i][j - 1];
      g[path[i][j - 1]].push_back(path[i][j]);
      mark[path[i][j]] = true;
    }
  }
  vector<pair<int, int> > lf;
  for (int i = 0; i < n; i++)
    if (!mark[i])
      lf.push_back({d[0][i], i});
    else
      v[i].push_back(i);
  sort(lf.begin(), lf.end());
  for (pair<int, int> i : lf) {
    int u = i.second;
    pair<int, int> pv = {-1, -1};
    for (int j = 0; j < s.size(); j++) {
      int depth_lca = d[0][s[j]] + d[0][u] - d[j][u];
      if (depth_lca & 1) bad();
      depth_lca /= 2;
      pv = max(pv, make_pair(depth_lca, path[j][depth_lca]));
    }
    v[pv.second].push_back(u);
  }
  for (int i = 0; i < n; i++) {
    int pv = -1;
    for (int j = 1; j < v[i].size(); j++) {
      if (d[0][v[i][j - 1]] < d[0][v[i][j]]) pv = v[i][j - 1];
      if (pv == -1 || d[0][pv] + 1 != d[0][v[i][j]]) bad();
      p[v[i][j]] = pv;
    }
  }
  for (int i = 0; i < n; i++) {
    if (p[i] != -1) cout << i + 1 << " " << p[i] + 1 << "\n";
  }
  return 0;
}
