Problem: Petya had a tree consisting of n vertices numbered with integers from 1 to n. Accidentally he lost his tree. 

Petya remembers information about k vertices: distances from each of them to each of the n tree vertices.

Your task is to restore any tree that satisfies the information that Petya remembers or report that such tree doesn't exist.

Input

The first line contains two integers n and k (2 ≤ n ≤ 30 000, 1 ≤ k ≤ min(200, n)) — the number of vertices in the tree and the number of vertices about which Petya remembers distance information.

The following k lines contain remembered information. The i-th line contains n integers di, 1, di, 2, ..., di, n (0 ≤ di, j ≤ n - 1), where di, j — the distance to j-th vertex from the i-th vertex that Petya remembers.

Output

If there are no suitable trees, print -1.

In the other case, print n - 1 lines: each line should contain two vertices connected by edge in the required tree. You can print edges and vertices in an edge in any order. The tree vertices are enumerated from 1 to n.

If there are many solutions print any of them.

Examples

Input

5 2
0 1 2 3 2
2 1 0 1 2


Output

2 1
3 2
4 3
5 2


Input

3 1
1 2 1


Output

-1

Note

Picture for the first sample:

<image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  assert(y >= 0);
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et() {
  puts("-1");
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 1000000007) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) {
  long long z = y;
  while (x % y != 0) {
    z = x % y;
    x = y;
    y = z;
  }
  return z;
}
int d[202][30015];
int who[202];
int disv[202][30015], rt, fa[30015];
bool vis[30015];
vector<pair<int, int> > vp[30015];
void read(int &x) {
  char ch = getchar();
  x = 0;
  for (; ch < '0' || ch > '9'; ch = getchar())
    ;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
}
void fmain(int tid) {
  scanf("%d%d", &n, &k);
  for (int(i) = 1; (i) <= (int)(k); (i)++) {
    for (int(j) = 1; (j) <= (int)(n); (j)++) read(d[i][j]);
    for (int(j) = 1; (j) <= (int)(n); (j)++)
      if (d[i][j] == 0) {
        if (who[i] == 0)
          who[i] = j;
        else
          et();
      }
    if (who[i] == 0) et();
  }
  rt = who[1];
  for (int i = 2; i <= k; i++) {
    int v = who[i];
    for (int(j) = 1; (j) <= (int)(n); (j)++)
      if (j != rt) {
        if (d[1][j] + d[i][j] == d[1][v]) {
          if (disv[i][d[1][j]] != 0) et();
          disv[i][d[1][j]] = j;
        }
      }
    disv[i][0] = rt;
    for (int(j) = 1; (j) <= (int)(d[1][v]); (j)++) {
      if (disv[i][j] == 0) {
        et();
      }
      fa[disv[i][j]] = disv[i][j - 1];
      vis[disv[i][j]] = 1;
    }
  }
  for (int(i) = 1; (i) <= (int)(n); (i)++)
    if (i != rt && !vis[i]) {
      int dd = 0, node = rt;
      for (int j = 2; j <= k; j++) {
        int tmp = (d[1][who[j]] + d[1][i] - d[j][i]) / 2;
        if (tmp > dd) {
          dd = tmp;
          node = disv[j][tmp];
        }
      }
      vp[node].push_back({d[1][i], i});
    }
  for (int(i) = 1; (i) <= (int)(n); (i)++)
    if (!vp[i].empty()) {
      sort(vp[i].begin(), vp[i].end());
      int D = d[1][i], pa = i;
      for (int(j) = 0; (j) < (int)(vp[i].size()); (j)++) {
        auto p = vp[i][j];
        if (p.first == D + 1) {
        } else {
          if (p.first != D + 2) et();
          if (j == 0) et();
          pa = vp[i][j - 1].second;
          D++;
        }
        fa[p.second] = pa;
      }
    }
  for (int(i) = 1; (i) <= (int)(n); (i)++)
    if (i != rt) {
      printf("%d %d\n", i, fa[i]);
    }
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}