#include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  assert(y >= 0);
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et() {
  puts("-1");
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 1000000007) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) {
  long long z = y;
  while (x % y != 0) {
    z = x % y;
    x = y;
    y = z;
  }
  return z;
}
int d[202][30015];
int who[202];
int disv[202][30015], rt, fa[30015];
bool vis[30015];
vector<pair<int, int> > vp[30015];
void read(int &x) {
  char ch = getchar();
  x = 0;
  for (; ch < '0' || ch > '9'; ch = getchar())
    ;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
}
void fmain(int tid) {
  scanf("%d%d", &n, &k);
  for (int(i) = 1; (i) <= (int)(k); (i)++) {
    for (int(j) = 1; (j) <= (int)(n); (j)++) read(d[i][j]);
    for (int(j) = 1; (j) <= (int)(n); (j)++)
      if (d[i][j] == 0) {
        if (who[i] == 0)
          who[i] = j;
        else
          et();
      }
    if (who[i] == 0) et();
  }
  rt = who[1];
  for (int i = 2; i <= k; i++) {
    int v = who[i];
    for (int(j) = 1; (j) <= (int)(n); (j)++)
      if (j != rt) {
        if (d[1][j] + d[i][j] == d[1][v]) {
          if (disv[i][d[1][j]] != 0) et();
          disv[i][d[1][j]] = j;
        }
      }
    disv[i][0] = rt;
    for (int(j) = 1; (j) <= (int)(d[1][v]); (j)++) {
      if (disv[i][j] == 0) {
        et();
      }
      fa[disv[i][j]] = disv[i][j - 1];
      vis[disv[i][j]] = 1;
    }
  }
  for (int(i) = 1; (i) <= (int)(n); (i)++)
    if (i != rt && !vis[i]) {
      int dd = 0, node = rt;
      for (int j = 2; j <= k; j++) {
        int tmp = (d[1][who[j]] + d[1][i] - d[j][i]) / 2;
        if (tmp > dd) {
          dd = tmp;
          node = disv[j][tmp];
        }
      }
      vp[node].push_back({d[1][i], i});
    }
  for (int(i) = 1; (i) <= (int)(n); (i)++)
    if (!vp[i].empty()) {
      sort(vp[i].begin(), vp[i].end());
      int D = d[1][i], pa = i;
      for (int(j) = 0; (j) < (int)(vp[i].size()); (j)++) {
        auto p = vp[i][j];
        if (p.first == D + 1) {
        } else {
          if (p.first != D + 2) et();
          if (j == 0) et();
          pa = vp[i][j - 1].second;
          D++;
        }
        fa[p.second] = pa;
      }
    }
  for (int(i) = 1; (i) <= (int)(n); (i)++)
    if (i != rt) {
      printf("%d %d\n", i, fa[i]);
    }
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
