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>
const int base = 1000003;
int n, k, d[201][30001], v[201];
bool isv[30010];
int fa[30010], tmp[30010];
bool on[30010];
struct edge {
  int to;
  edge* next;
} E[60010], *ne = E, *first[30010];
void link(int u, int v) {
  *ne = (edge){v, first[u]};
  first[u] = ne++;
}
bool chk(int i, int f, int d, int* g) {
  if (d != g[i]) return 0;
  for (edge* e = first[i]; e; e = e->next)
    if (e->to != f && !chk(e->to, i, d + 1, g)) return 0;
  return 1;
}
int list[30010], len;
bool cmp(int i, int j) { return d[0][i] < d[0][j]; }
unsigned long long hval[30010], hadd;
std::map<unsigned long long, int> M;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < k; i++) {
    int fd = 0;
    for (int j = 0; j < n; j++)
      scanf("%d", d[i] + j), !d[i][j] ? fd++, v[i] = j : 1;
    if (fd != 1) return puts("-1"), 0;
    fd = 0;
    for (int j = 0; j < i; j++)
      if (v[j] == v[i]) {
        fd = 1;
        for (int x = 0; x < n; x++)
          if (d[j][x] != d[i][x]) return puts("-1"), 0;
      }
    if (fd) i--, k--;
    isv[v[i]] = 1;
  }
  on[v[0]] = 1;
  for (int i = 0; i < n; i++) fa[i] = -1;
  for (int i = 1; i < k; i++) {
    int x = v[i];
    for (int j = 0; j <= d[0][x]; j++) tmp[j] = -1;
    for (int j = 0; j < n; j++)
      if (d[0][j] + d[i][j] == d[0][x]) {
        if (tmp[d[0][j]] > -1) return puts("-1"), 0;
        tmp[d[0][j]] = j;
      }
    for (int j = 0; j <= d[0][x]; j++) {
      if (tmp[j] < 0) return puts("-1"), 0;
      if (j) {
        if (fa[tmp[j]] > -1 && fa[tmp[j]] != tmp[j - 1]) return puts("-1"), 0;
        fa[tmp[j]] = tmp[j - 1];
        on[tmp[j]] = 1;
      }
    }
  }
  for (int i = 0; i < n; i++)
    if (on[i] && fa[i] > -1) link(i, fa[i]), link(fa[i], i);
  for (int i = 0; i < k; i++)
    if (!chk(v[i], -1, 0, d[i])) return puts("-1"), 0;
  for (int i = 0; i < k; i++) hadd = hadd * base + 1;
  for (int i = 0; i < n; i++) {
    for (int j = k; j--;) hval[i] = hval[i] * base + d[j][i];
    if (on[i]) M[hval[i]] = i;
  }
  for (int i = 0; i < n; i++)
    if (!on[i]) list[len++] = i;
  std::sort(list, list + len, cmp);
  for (int* i = list; i < list + len; i++) {
    unsigned long long h = hval[*i] - hadd;
    if (!M.count(h)) return puts("-1"), 0;
    fa[*i] = M[h];
    M[hval[*i]] = *i;
  }
  for (int i = 0; i < n; i++)
    if (fa[i] > -1) printf("%d %d\n", i + 1, fa[i] + 1);
}