#include <bits/stdc++.h>
using namespace std;
const int N = 30005, K = 205;
int a[K][N], q[K][N];
int vis[N], pre[N];
vector<pair<int, int> > vec[N];
int n, k, id[N];
void GG() {
  puts("-1");
  exit(0);
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = (int)(1); i <= (int)(k); i++)
    for (int j = (int)(1); j <= (int)(n); j++) {
      scanf("%d", &a[i][j]);
      if (!a[i][j]) id[i] = j;
    }
  for (int i = (int)(1); i <= (int)(k); i++)
    if (!id[i]) GG();
  for (int i = (int)(2); i <= (int)(k); i++) {
    for (int j = (int)(1); j <= (int)(n); j++)
      if (a[1][j] + a[i][j] == a[1][id[i]]) q[i][a[1][j]] = j, vis[j] = 1;
    for (int j = (int)(a[1][id[i]]); j >= (int)(1); j--) {
      if (!q[i][j]) break;
      pre[q[i][j]] = q[i][j - 1];
    }
  }
  vis[id[1]] = 1;
  for (int i = (int)(1); i <= (int)(n); i++)
    if (!vis[i]) {
      int at = id[1], mn = 0;
      for (int j = (int)(2); j <= (int)(k); j++) {
        int v = (a[1][id[j]] + a[1][i] - a[j][i]) / 2;
        if (v >= mn) mn = v, at = q[j][v];
      }
      vec[at].push_back(pair<int, int>(a[1][i], i));
    }
  for (int j = (int)(1); j <= (int)(n); j++) {
    sort(vec[j].begin(), vec[j].end());
    for (int i = 0, la = a[1][j], cur = j; i < vec[j].size();) {
      if ((++la) != vec[j][i].first) GG();
      for (; i < vec[j].size() - 1 && vec[j][i + 1].first == la;)
        pre[vec[j][i++].second] = cur;
      pre[vec[j][i].second] = cur;
      cur = vec[j][i++].second;
    }
  }
  for (int i = (int)(1); i <= (int)(n); i++)
    if (pre[i]) printf("%d %d\n", i, pre[i]);
}
