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;
namespace FastIO {
const int SZB = 2333333;
char LZH[SZB], *SSS = LZH, *TTT = LZH;
int read() {
  int x = 0;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    ;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 - 48 + ch;
  return x;
}
}  // namespace FastIO
using namespace FastIO;
int a[205][30005], q[205][30005], vis[30005], pre[30005];
vector<pair<int, int> > h[30005];
int n, k, id[30005];
int main() {
  n = read();
  k = read();
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= n; j++)
      if (!(a[i][j] = read())) id[i] = j;
    if (!id[i]) return puts("-1"), 0;
  }
  for (int i = 2; i <= k; i++) {
    for (int j = 1; j <= n; j++)
      if (a[1][j] + a[i][j] == a[1][id[i]]) q[i][a[1][j]] = j, vis[j] = 1;
    for (int j = a[1][id[i]]; j; j--) {
      if (!q[i][j]) return puts("-1"), 0;
      pre[q[i][j]] = q[i][j - 1];
    }
  }
  vis[id[1]] = 1;
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      int cho = id[1], mn = 0, now;
      for (int j = 2; j <= k; j++) {
        now = (a[1][id[j]] + a[1][i] - a[j][i]) / 2;
        if (now >= mn) mn = now, cho = q[j][now];
      }
      h[cho].push_back(make_pair(a[1][i], i));
    }
  for (int j = 1; j <= n; j++) {
    sort(h[j].begin(), h[j].end());
    for (int i = 0, la = a[1][j], cur = j; i < h[j].size();) {
      if ((++la) != h[j][i].first) return puts("-1"), 0;
      for (; i < h[j].size() - 1 && h[j][i + 1].first == la;)
        pre[h[j][i++].second] = cur;
      pre[h[j][i].second] = cur;
      cur = h[j][i++].second;
    }
  }
  for (int i = 1; i <= n; i++)
    if (pre[i]) printf("%d %d\n", pre[i], i);
}