#include <bits/stdc++.h>
const int M1 = 998244353, M2 = 1e9 + 7;
std::map<int, bool> E[30010];
int n, k, d[210][30010], M[210], *m[210], b[30010], D1[30010], D2[30010];
bool vis[30010];
struct Hash {
  int Point[19260817], Next[30010], q, H1[30010], H2[30010], f[30010];
  void Add(int h1, int h2, int p) {
    int t = (h1 ^ h2) % 19260817;
    for (int j = Point[t]; j; j = Next[j])
      if (H1[j] == h1 && H2[j] == h2) return;
    Next[++q] = Point[t];
    Point[t] = q;
    H1[q] = h1;
    H2[q] = h2;
    f[q] = p;
  }
  int find(int h1, int h2) {
    int t = (h1 ^ h2) % 19260817;
    for (int j = Point[t]; j; j = Next[j])
      if (H1[j] == h1 && H2[j] == h2) return f[j];
    return 0;
  }
} H;
bool cmp(const int *i, const int *j) { return d[1][*i] < d[1][*j]; }
bool cmp1(const int &i, const int &j) { return d[1][i] < d[1][j]; }
struct pair {
  int u, v;
} Ans[30010];
int tot;
void Add(int u, int v) { Ans[++tot] = (pair){u, v}; }
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; ++i) D1[i] = rand();
  for (int i = 1; i <= n; ++i) D2[i] = rand();
  for (int i = 1; i <= k; ++i) {
    for (int j = 1; j <= n; ++j) {
      scanf("%d", &d[i][j]);
      if (!d[i][j]) {
        {
          if (M[i]) {
            puts("-1");
            return 0;
          }
        };
        M[i] = j;
      }
    }
    {
      if (!M[i]) {
        puts("-1");
        return 0;
      }
    };
  }
  for (int i = 2; i <= k; ++i) m[i] = M + i;
  std::sort(m + 2, m + k + 1, cmp);
  for (int i = 1; i <= n; ++i) b[i] = i;
  std::sort(b + 1, b + n + 1, cmp1);
  vis[M[1]] = 1;
  for (int i = 2; i <= k; ++i) {
    int now = M[1], dis = d[1][*m[i]];
    for (int *j = b + 2; j <= b + n && now != *m[i]; ++j) {
      if (d[m[i] - M][*j] + d[1][*j] == dis) {
        if (!E[now][*j]) {
          Add(now, *j);
          E[now][*j] = 1;
          vis[*j] = 1;
        }
        now = *j;
      }
    }
    {
      if (now != *m[i]) {
        puts("-1");
        return 0;
      }
    };
  }
  for (int i = 1; i <= n; ++i)
    if (vis[i]) {
      int h1 = 0, h2 = 0;
      for (int j = 1; j <= k; ++j)
        h1 = (1ll * h1 * 137 + 1ll * D1[j] * d[j][i]) % M1;
      for (int j = 1; j <= k; ++j)
        h2 = (1ll * h2 * 117 + 1ll * D2[j] * d[j][i]) % M2;
      H.Add(h1, h2, i);
    }
  for (int *i = b + 1; i <= b + n; ++i)
    if (!vis[*i]) {
      int h1 = 0, h2 = 0, pos;
      for (int j = 1; j <= k; ++j)
        h1 = (1ll * h1 * 137 + 1ll * D1[j] * (d[j][*i] - 1)) % M1;
      for (int j = 1; j <= k; ++j)
        h2 = (1ll * h2 * 117 + 1ll * D2[j] * (d[j][*i] - 1)) % M2;
      {
        if (!(pos = H.find(h1, h2))) {
          puts("-1");
          return 0;
        }
      };
      Add(pos, *i);
      h1 = h2 = 0;
      for (int j = 1; j <= k; ++j)
        h1 = (1ll * h1 * 137 + 1ll * D1[j] * d[j][*i]) % M1;
      for (int j = 1; j <= k; ++j)
        h2 = (1ll * h2 * 117 + 1ll * D2[j] * d[j][*i]) % M2;
      H.Add(h1, h2, *i);
    }
  for (pair *i = Ans + 1; i < Ans + n; ++i) printf("%d %d\n", i->u, i->v);
  return 0;
}
