#include <bits/stdc++.h>
using namespace std;
const int N = 30010, K = 210;
const unsigned long long base1 = 398989, base2 = 1145141;
vector<int> v[N];
map<int, bool> E[N];
map<pair<unsigned long long, unsigned long long>, int> ma;
int n, k, ans[N][2], tmp[N], key[K], rt, vis[N], gcnt;
pair<int, int> a[N];
void add(int x, int y) {
  E[x][y] = 1, E[y][x] = 1;
  ans[++gcnt][0] = x, ans[gcnt][1] = y;
  vis[x] = vis[y] = 1;
}
int main() {
  int i, j, k, x, y, z;
  unsigned long long h1, h2;
  scanf("%d%d", &n, &k);
  for (i = 1; i <= n; i++) v[i].push_back(0);
  for (i = 1; i <= k; i++) {
    for (j = 1; j <= n; j++) scanf("%d", &tmp[j]);
    for (j = 1; j <= n; j++)
      if (tmp[j] == 0) break;
    if (j == n + 1) cout << -1, exit(0);
    x = j;
    for (j = j + 1; j <= n; j++)
      if (tmp[j] == 0) cout << -1, exit(0);
    key[i] = x;
    for (j = 1; j <= n; j++) v[x].push_back(tmp[j]);
  }
  rt = key[1];
  for (i = 1; i <= n; i++) a[i] = make_pair(v[rt][i], i);
  sort(a + 1, a + n + 1);
  vis[rt] = 1;
  for (i = 2; i <= k; i++) {
    x = rt;
    for (j = 2; j <= n; j++) {
      y = a[j].second;
      if (a[j].first + v[key[i]][y] == v[rt][key[i]]) {
        if (!E[x][y]) add(x, y);
        x = y;
      }
    }
  }
  for (i = 1; i <= n; i++) {
    if (!vis[i]) continue;
    h1 = h2 = 0;
    for (j = 1; j <= k; j++) h1 = h1 * base1 + v[key[j]][i];
    for (j = 1; j <= k; j++) h2 = h2 * base2 + v[key[j]][i];
    ma[make_pair(h1, h2)] = i;
  }
  for (i = 2; i <= n; i++) {
    x = a[i].second;
    if (vis[x]) continue;
    h1 = h2 = 0;
    for (j = 1; j <= k; j++) h1 = h1 * base1 + v[key[j]][x] - 1;
    for (j = 1; j <= k; j++) h2 = h2 * base2 + v[key[j]][x] - 1;
    if (ma.find(make_pair(h1, h2)) == ma.end()) cout << -1, exit(0);
    add(ma[make_pair(h1, h2)], x);
    h1 = h2 = 0;
    for (j = 1; j <= k; j++) h1 = h1 * base1 + v[key[j]][x];
    for (j = 1; j <= k; j++) h2 = h2 * base2 + v[key[j]][x];
    ma[make_pair(h1, h2)] = x;
  }
  for (i = 1; i < n; i++) printf("%d %d\n", ans[i][0], ans[i][1]);
  return ~~(0 - 0);
}
