#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
const long long ooo = 9223372036854775807ll;
const int _cnt = 1000 * 1000 + 7;
const int _p = 1000 * 1000 * 1000 + 7;
const int N = 200105;
const double PI = acos(-1.0);
const double eps = 1e-6;
int o(int x) { return x % _p; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
void file_put() {
  freopen("filename.in", "r", stdin);
  freopen("filename.out", "w", stdout);
}
int n, m, k, d[205][30015], p[205][30015], pre[30015], id[205], dd[30015], mx,
    t, tt;
bool v[30015];
vector<int> V[30015];
bool cmp(int x, int y) { return dd[x] < dd[y]; }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (1); i <= (m); ++i)
    for (int j = (1); j <= (n); ++j) {
      scanf("%d", &d[i][j]);
      if (!d[i][j])
        if (!id[i])
          id[i] = j;
        else
          return 0 * puts("-1");
    }
  for (int i = (1); i <= (m); ++i)
    if (!id[i]) return 0 * puts("-1");
  for (int i = (1); i <= (n); ++i) dd[i] = d[1][i];
  p[1][0] = id[1], v[id[1]] = 1;
  for (int i = (2); i <= (m); ++i) {
    for (int j = (1); j <= (n); ++j)
      if (dd[j] + d[i][j] == dd[id[i]]) p[i][dd[j]] = j, v[j] = 1;
    for (int j = (1); j <= (dd[id[i]]); ++j) {
      if (!p[i][j]) return 0 * puts("-1");
      pre[p[i][j]] = p[i][j - 1];
    }
  }
  for (int i = (1); i <= (n); ++i)
    if (!v[i]) {
      mx = -oo;
      for (int j = (1); j <= (m); ++j) {
        t = dd[i] + dd[id[j]] - d[j][i] >> 1;
        if (t > mx) mx = t, tt = p[j][t];
      }
      V[tt].push_back(i);
    }
  for (int i = (1); i <= (n); ++i)
    if (v[i]) {
      sort((V[i]).begin(), (V[i]).end(), cmp);
      t = i;
      for (int j = (0); j <= ((int)V[i].size() - 1); ++j) {
        if (j && dd[V[i][j]] != dd[V[i][j - 1]]) t = V[i][j - 1];
        if (dd[V[i][j]] != dd[t] + 1) return 0 * puts("-1");
        pre[V[i][j]] = t;
      }
    }
  for (int i = (1); i <= (n); ++i)
    if (i != id[1]) printf("%d %d\n", i, pre[i]);
  return 0;
}
