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;
int fa[30005];
int d[305][30005];
int id[305];
vector<int> nx[30005];
int n, k;
int dep[30005];
void dfs(int a, int fa) {
  for (int j = 0; j < nx[a].size(); j++) {
    int ns = nx[a][j];
    if (ns == fa) continue;
    dep[ns] = dep[a] + 1, dfs(ns, a);
  }
}
int tr[30005];
bool check() {
  bool flag = 1;
  for (int i = 1; i <= n; i++)
    if (fa[i]) nx[i].push_back(fa[i]), nx[fa[i]].push_back(i);
  for (int i = 1; i <= k; i++) {
    dep[tr[i]] = 0;
    dfs(tr[i], 0);
    for (int j = 1; j <= n; j++)
      if (dep[j] != d[i][j] || (!d[i][j] && j != tr[i])) flag = 0;
  }
  if (!flag) return 0;
  return 1;
}
int fas[305][30005];
int npl[30005];
struct th {
  int id, dep;
  bool operator<(const th &a) const { return dep < a.dep; }
} p[30005];
int nnod[30005][2];
bool hv[30005];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++)
    for (int j = 1; j <= n; j++) {
      scanf("%d", &d[i][j]);
      if (!d[i][j]) tr[i] = j, hv[j] = 1;
    }
  int root = 1;
  for (int i = 2; i <= k; i++) {
    for (int j = 1; j <= n; j++)
      if (d[1][j] + d[i][j] == d[1][tr[i]]) npl[d[1][j]] = j;
    for (int j = 1; j <= d[1][tr[i]]; j++) fa[npl[j]] = npl[j - 1];
    for (int j = 1; j <= d[1][tr[i]]; j++) fas[i][j] = npl[d[1][tr[i]] - j];
    fas[i][0] = tr[i];
  }
  int ncnt = 0;
  for (int i = 1; i <= n; i++)
    if (fa[i] || i == tr[1])
      continue;
    else
      p[ncnt].id = i, p[ncnt++].dep = d[1][i];
  sort(p, p + ncnt);
  for (int i = 0; i < ncnt; i++) {
    if (i && p[i].dep != p[i - 1].dep)
      for (int j = 1; j <= n; j++) nnod[j][0] = nnod[j][1], nnod[j][1] = 0;
    int nd = p[i].dep, id = p[i].id;
    int pre = tr[1];
    for (int j = 2; j <= k; j++) {
      int dv = (d[j][id] + d[1][tr[j]] - d[1][id]) / 2;
      int nfa = fas[j][(d[j][id] + d[1][tr[j]] - d[1][id]) / 2];
      if (d[1][nfa] > d[1][pre]) pre = nfa;
    }
    if (nnod[pre][0])
      fa[id] = nnod[pre][0];
    else
      fa[id] = pre;
    nnod[pre][1] = id;
  }
  if (check()) {
    for (int i = 1; i <= n; i++)
      if (fa[i]) printf("%d %d\n", i, fa[i]);
  } else
    printf("-1\n");
  return 0;
}