#include <bits/stdc++.h>
using namespace std;
const int K = 202;
const int N = 3e4 + 2;
const int inf = 1e9 + 7;
int dis[K][N], idx[K], par[N];
int ver[K][N];
pair<int, int> lst[N], lis[N];
bool used[N];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, num, i, j, k, l, cnt = 0;
  cin >> n >> num;
  for (i = 1; i <= num; i++) {
    for (j = 1; j <= n; j++) {
      cin >> dis[i][j];
      if (dis[i][j] == 0) {
        if (!idx[i]) {
          idx[i] = j;
        } else {
          cout << -1;
          return 0;
        }
      }
    }
    if (!idx[i]) {
      cout << -1;
      return 0;
    }
    used[idx[i]] = true;
    lst[idx[i]].first = idx[i];
    lst[idx[i]].second = dis[1][idx[i]];
  }
  for (i = 1; i <= num; i++) {
    for (j = i + 1; j <= num; j++) {
      if (dis[i][idx[j]] != dis[j][idx[i]]) {
        cout << -1;
        return 0;
      }
      if (idx[i] == idx[j]) {
        cout << -1;
        return 0;
      }
    }
  }
  ver[1][0] = idx[1];
  int root = idx[1];
  for (i = 2; i <= num; i++) {
    for (j = 1; j <= n; j++) {
      if (dis[1][j] + dis[i][j] == dis[1][idx[i]]) {
        if (!ver[i][dis[1][j]]) {
          ver[i][dis[1][j]] = j;
        } else {
          cout << -1;
          return 0;
        }
      }
    }
    for (j = 0; j <= dis[1][idx[i]]; j++) {
      if (!ver[i][j]) {
        cout << -1;
        return 0;
      }
      if (j) {
        if (!par[ver[i][j]]) {
          par[ver[i][j]] = ver[i][j - 1];
        } else {
          if (par[ver[i][j]] != ver[i][j - 1]) {
            cout << -1;
            return 0;
          }
        }
      }
      lst[ver[i][j]].first = ver[i][j];
      lst[ver[i][j]].second = dis[1][ver[i][j]];
      used[ver[i][j]] = true;
    }
  }
  for (i = 1; i <= n; i++) {
    if (!used[i]) {
      cnt++;
      lis[cnt].first = dis[1][i];
      lis[cnt].second = i;
    }
  }
  sort(lis + 1, lis + 1 + cnt);
  i = j = 1;
  while (i <= cnt) {
    while (j <= cnt && lis[i].first == lis[j].first) {
      j++;
    }
    for (k = i; k < j; k++) {
      int u = lis[k].second;
      int lca = idx[1];
      for (l = 1; l <= num; l++) {
        int wow = (dis[1][idx[l]] + dis[1][u] - dis[l][u]) / 2;
        int v = ver[l][wow];
        if (dis[1][lca] < dis[1][v]) {
          lca = v;
        }
      }
      if (lst[lca].second + 1 != dis[1][u]) {
        cout << -1;
        return 0;
      }
      par[u] = lst[lca].first;
    }
    for (k = i; k < j; k++) {
      int u = lis[k].second;
      int lca = idx[1];
      for (l = 1; l <= num; l++) {
        int wow = (dis[1][idx[l]] + dis[1][u] - dis[l][u]) / 2;
        int v = ver[l][wow];
        if (dis[1][lca] < dis[1][v]) {
          lca = v;
        }
      }
      lst[lca].second = dis[1][u];
      lst[lca].first = u;
    }
    i = j;
  }
  for (i = 1; i <= n; i++) {
    if (i == idx[1]) {
      continue;
    }
    cout << par[i] << ' ' << i << '\n';
  }
}
