#include <bits/stdc++.h>
using namespace std;
const int N = 64000;
int par[N], n, dis[N], disp[N], dit[N];
vector<int> tr[N];
vector<pair<int, int> > subtr[N];
bool ok[N];
void endd() {
  puts("-1");
  exit(0);
}
void pathfind(int v) {
  int p = par[v];
  int ps[N] = {};
  fill(ps, ps + 2 * n, -1);
  ps[disp[v] + n] = v;
  ps[-disp[v] + n] = p;
  for (int i = 0; i < n; i++)
    if (par[i] == p) {
      int d = disp[i] - dis[i] + n;
      if (ps[d] == -1 || dis[i] < dis[ps[d]]) ps[d] = i;
    }
  for (int i = 0; i < n; i++)
    if (par[i] == p) {
      int d = disp[i] - dis[i] + n;
      if (ps[d] != -1 && dis[i] == dis[ps[d]] && i != ps[d]) endd();
    }
  for (int i = 2; i < 2 * n; i++)
    if (ps[i] != -1 && ps[i - 2] != -1) {
      int a = ps[i], b = ps[i - 2];
      tr[a].push_back(b);
      tr[b].push_back(a);
      ok[a] = true;
    }
  for (int i = 0; i < n; i++)
    if (par[i] == p) {
      int d = disp[i] - dis[i] + n;
      par[i] = ps[d];
      int dtopar = dis[i] - dis[par[i]];
      if (i != par[i] && par[i] != p)
        subtr[ps[d]].push_back(make_pair(i, dtopar));
    }
  vector<pair<int, int> > vt;
  for (int i = 0; i < subtr[p].size(); i++) {
    auto u = subtr[p][i];
    if (par[u.first] == p) vt.push_back(u);
  }
  subtr[p] = vt;
}
void dfs(int x, int p, int* a) {
  a[x] = 0;
  if (p != -1) a[x] = a[p] + 1;
  for (auto u : subtr[x]) a[u.first] = a[x] + u.second;
  for (auto u : tr[x])
    if (u != p) dfs(u, x, a);
}
void find(int v, int* a) {
  memset(a, 0, sizeof a);
  dfs(v, -1, a);
}
int main() {
  int k;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    int v = -1;
    bool has[N] = {};
    for (int j = 0; j < n; j++) {
      scanf("%d", &dis[j]);
      has[dis[j]] = true;
      if (dis[j] == 0) {
        if (v != -1) endd();
        v = j;
      }
    }
    if (v == -1) endd();
    int mx = *max_element(dis, dis + n);
    for (int i = 0; i < mx; i++)
      if (!has[i]) endd();
    if (!i) {
      ok[v] = true;
      for (int j = 0; j < n; j++) {
        par[j] = v;
        if (j != v) subtr[v].push_back(make_pair(j, dis[j]));
      }
      continue;
    }
    int p = par[v];
    find(par[v], disp);
    if (!ok[v]) pathfind(v);
    find(p, dit);
    for (int i = 0; i < n; i++)
      if (disp[i] != dit[i]) endd();
    find(v, disp);
    for (int i = 0; i < n; i++)
      if (disp[i] != dis[i]) endd();
    ok[v] = true;
  }
  for (int i = 0; i < n; i++) {
    int pre[N] = {i};
    for (auto u : tr[i])
      if (u > i) cout << u + 1 << ' ' << i + 1 << endl;
    for (auto u : subtr[i]) pre[u.second] = u.first;
    for (auto u : subtr[i])
      cout << u.first + 1 << ' ' << pre[u.second - 1] + 1 << endl;
  }
  return 0;
}
