#include <bits/stdc++.h>
const int mod = 1e9 + 7;
using namespace std;
int n, k, dis[211][100010], id[211], vis[100010];
int fa[100010];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%d", &dis[i][j]);
      if (!dis[i][j]) {
        if (id[i])
          return puts("-1"), 0;
        else
          id[i] = j;
      }
    }
    if (!id[i]) return puts("-1"), 0;
    if (vis[id[i]]) return puts("-1"), 0;
    vis[id[i]] = 1;
  }
  int rt = id[1];
  vector<int> ps[k + 1];
  for (int i = 1; i <= k; i++) ps[i] = vector<int>();
  for (int t = 2; t <= k; t++) {
    int v = id[t];
    vector<int> par(n + 1, -1);
    for (int u = 1; u <= n; u++) {
      if (dis[t][u] + dis[1][u] == dis[1][v]) {
        if (par[dis[1][u]] != -1) return puts("-1"), 0;
        par[dis[1][u]] = u;
      }
    }
    for (int i = 0; i < n; i++) {
      if (par[i] == -1 && i <= dis[1][v]) return puts("-1"), 0;
      if (par[i] != -1 && i > dis[1][v]) return puts("-1"), 0;
    }
    for (int i = 0; i < dis[1][v]; i++) {
      int p = par[i], u = par[i + 1];
      if (fa[u] != 0 && fa[u] != p) return puts("-1"), 0;
      fa[u] = p;
    }
    ps[t] = par;
  }
  if (fa[rt] != 0) return puts("-1"), 0;
  vector<int> subs[n + 1];
  for (int i = 0; i <= n; i++) subs[i] = vector<int>();
  vector<int> vh[n + 1];
  for (int i = 0; i <= n; i++) vh[i] = vector<int>();
  for (int i = 1; i <= n; i++) vh[dis[1][i]].push_back(i);
  for (int h = 0; h < n; h++) {
    for (int v : vh[h]) {
      if (v == rt || fa[v] != 0) continue;
      int lp = rt, lt = 1;
      for (int t = 2; t <= k; t++) {
        int u = id[t];
        int hl2 = dis[1][u] + dis[1][v] - dis[t][v];
        if (hl2 & 1) return puts("-1"), 0;
        int hl = hl2 / 2;
        if (hl < 0 || hl > dis[1][u] || hl > dis[1][v]) return puts("-1"), 0;
        int l = ps[t][hl];
        if (dis[1][l] >= dis[1][lp]) {
          if (ps[t][dis[1][lp]] != lp) return puts("-1"), 0;
          lp = l;
          lt = t;
        } else {
          if (ps[lt][dis[1][l]] != l) return puts("-1"), 0;
        }
      }
      subs[lp].push_back(v);
    }
  }
  for (int i = 1; i <= n; i++) {
    int pre = i, nxt = -1;
    for (int v : subs[i]) {
      if (dis[1][v] == dis[1][pre] + 1) {
        fa[v] = pre;
        nxt = v;
      } else {
        pre = nxt;
        if (pre != -1 && dis[1][v] == dis[1][pre] + 1) {
          fa[v] = pre;
          nxt = v;
        } else
          return puts("-1"), 0;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (i == rt)
      continue;
    else
      printf("%d %d\n", i, fa[i]);
  }
  return 0;
}
