#include <bits/stdc++.h>
const int base = 1000003;
int n, k, d[201][30001], v[201];
bool isv[30010];
int fa[30010], tmp[30010];
bool on[30010];
struct edge {
  int to;
  edge* next;
} E[60010], *ne = E, *first[30010];
void link(int u, int v) {
  *ne = (edge){v, first[u]};
  first[u] = ne++;
}
bool chk(int i, int f, int d, int* g) {
  if (d != g[i]) return 0;
  for (edge* e = first[i]; e; e = e->next)
    if (e->to != f && !chk(e->to, i, d + 1, g)) return 0;
  return 1;
}
int list[30010], len;
bool cmp(int i, int j) { return d[0][i] < d[0][j]; }
unsigned long long hval[30010], hadd;
std::map<unsigned long long, int> M;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < k; i++) {
    int fd = 0;
    for (int j = 0; j < n; j++)
      scanf("%d", d[i] + j), !d[i][j] ? fd++, v[i] = j : 1;
    if (fd != 1) return puts("-1"), 0;
    fd = 0;
    for (int j = 0; j < i; j++)
      if (v[j] == v[i]) {
        fd = 1;
        for (int x = 0; x < n; x++)
          if (d[j][x] != d[i][x]) return puts("-1"), 0;
      }
    if (fd) i--, k--;
    isv[v[i]] = 1;
  }
  on[v[0]] = 1;
  for (int i = 0; i < n; i++) fa[i] = -1;
  for (int i = 1; i < k; i++) {
    int x = v[i];
    for (int j = 0; j <= d[0][x]; j++) tmp[j] = -1;
    for (int j = 0; j < n; j++)
      if (d[0][j] + d[i][j] == d[0][x]) {
        if (tmp[d[0][j]] > -1) return puts("-1"), 0;
        tmp[d[0][j]] = j;
      }
    for (int j = 0; j <= d[0][x]; j++) {
      if (tmp[j] < 0) return puts("-1"), 0;
      if (j) {
        if (fa[tmp[j]] > -1 && fa[tmp[j]] != tmp[j - 1]) return puts("-1"), 0;
        fa[tmp[j]] = tmp[j - 1];
        on[tmp[j]] = 1;
      }
    }
  }
  for (int i = 0; i < n; i++)
    if (on[i] && fa[i] > -1) link(i, fa[i]), link(fa[i], i);
  for (int i = 0; i < k; i++)
    if (!chk(v[i], -1, 0, d[i])) return puts("-1"), 0;
  for (int i = 0; i < k; i++) hadd = hadd * base + 1;
  for (int i = 0; i < n; i++) {
    for (int j = k; j--;) hval[i] = hval[i] * base + d[j][i];
    if (on[i]) M[hval[i]] = i;
  }
  for (int i = 0; i < n; i++)
    if (!on[i]) list[len++] = i;
  std::sort(list, list + len, cmp);
  for (int* i = list; i < list + len; i++) {
    unsigned long long h = hval[*i] - hadd;
    if (!M.count(h)) return puts("-1"), 0;
    fa[*i] = M[h];
    M[hval[*i]] = *i;
  }
  for (int i = 0; i < n; i++)
    if (fa[i] > -1) printf("%d %d\n", i + 1, fa[i] + 1);
}
