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;
const int N = 3e4 + 7, M = 2e2 + 7;
bool fl[N];
int n, k, tot, fs[N], sum[N], pos[M], f[M][N];
map<int, bool> s[N];
struct edge {
  int u, v;
} ed[N * M];
struct node {
  int ch[M], num;
} qt[N];
inline int read() {
  int num = 0;
  char g = getchar();
  while (g < 48 || 57 < g) g = getchar();
  while (47 < g && g < 58)
    num = (num << 1) + (num << 3) + g - 48, g = getchar();
  return num;
}
inline int find(int u) {
  if (fs[u] == u) return u;
  return fs[u] = find(fs[u]);
}
inline bool equals(node a, node b) {
  for (int i = 1; i <= k; i++)
    if (a.ch[i] + 1 != b.ch[i]) return false;
  return true;
}
inline bool cmp(node a, node b) {
  for (int i = 1; i <= k; i++) {
    if (a.ch[i] < b.ch[i]) return false;
    if (a.ch[i] > b.ch[i]) return true;
  }
  return false;
}
int main() {
  n = read(), k = read();
  for (int i = 1; i <= k; i++)
    for (int x = 1; x <= n; x++) f[i][x] = read();
  for (int i = 1; i <= k; i++)
    for (int x = 1; x <= n; x++)
      if (!f[i][x]) pos[i] = x;
  for (int i = 2; i <= k; i++) {
    memset(sum, 0, sizeof(sum));
    for (int c = 1; c <= n; c++)
      if (f[i][c] + f[1][c] == f[1][pos[i]]) sum[f[1][c]] = c;
    for (int c = 0; c <= f[1][pos[i]]; c++)
      if (!sum[c]) {
        puts("-1");
        return 0;
      }
    for (int c = 0; c < f[1][pos[i]]; c++)
      if (!s[sum[c]][sum[c + 1]])
        s[sum[c]][sum[c + 1]] = s[sum[c + 1]][sum[c]] = 1, ed[++tot].u = sum[c],
                          ed[tot].v = sum[c + 1];
  }
  for (int i = 1; i <= n; i++) fs[i] = i;
  for (int i = 1; i <= tot; i++) {
    int a = ed[i].u, b = ed[i].v;
    fl[a] = fl[b] = 1, fs[a] = find(a), fs[b] = find(b);
    if (fs[a] == fs[b]) {
      puts("-1");
      return 0;
    }
    fs[fs[a]] = find(b);
  }
  int tp = 1;
  for (int x = 1; x <= n; x++) {
    qt[x].num = x;
    for (int i = 1; i <= k; i++) qt[x].ch[i] = f[i][x];
  }
  for (int i = 1; i <= k; i++) fl[pos[i]] = 1;
  sort(qt + 1, qt + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    int c = qt[i].num;
    if (fl[c]) continue;
    while ((!equals(qt[tp], qt[i])) && tp <= n) tp++;
    if (tp > n) {
      puts("-1");
      return 0;
    }
    tot++, ed[tot].u = c, ed[tot].v = qt[tp].num;
  }
  for (int i = 1; i <= tot; i++) printf("%d %d\n", ed[i].u, ed[i].v);
  return 0;
}