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 + 100, M = 210;
int gi() {
  int w = 0;
  bool q = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') q = 0, c = getchar();
  while (c >= '0' && c <= '9') w = w * 10 + c - '0', c = getchar();
  return q ? w : -w;
}
void go() {
  puts("-1");
  exit(0);
}
int d[M][N], id[N];
int p[M][N], pre[N];
bool in[N];
int C;
int fa[N];
vector<int> e[N];
inline int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
vector<pair<int, int> > sub[N];
inline void link(int a, int b) {
  e[a].push_back(b);
  e[b].push_back(a);
}
int main() {
  int n = gi(), m = gi(), i, j, k, last, ld, t, mx, to;
  for (i = 1; i <= n; i++) fa[i] = i;
  for (i = 1; i <= m; i++) {
    for (j = 1; j <= n; j++)
      if (!(d[i][j] = gi())) id[i] = j;
    if (!id[i]) go();
  }
  p[1][0] = id[1];
  in[id[1]] = true;
  for (k = 2; k <= m; k++) {
    for (i = 1; i <= n; i++)
      if (d[1][i] + d[k][i] == d[1][id[k]]) p[k][d[1][i]] = i, in[i] = true;
    for (i = d[1][id[k]]; i; i--) {
      if (!p[k][i]) go();
      pre[p[k][i]] = p[k][i - 1];
    }
  }
  for (k = 1; k <= n; k++)
    if (!in[k]) {
      mx = -1;
      for (i = 1; i <= m; i++) {
        t = (d[1][id[i]] + d[1][k] - d[i][k]) / 2;
        if (t > mx) mx = t, to = p[i][t];
      }
      sub[to].push_back(make_pair(d[1][k], k));
    }
  for (k = 1; k <= n; k++) {
    sort(sub[k].begin(), sub[k].end());
    for (i = 0, last = k, ld = d[1][k]; i < sub[k].size(); i++) {
      if (i && sub[k][i].first != sub[k][i - 1].first)
        ld = d[1][last = sub[k][i - 1].second];
      if (sub[k][i].first != ld + 1) go();
      pre[sub[k][i].second] = last;
    }
  }
  for (i = 1; i <= n; i++)
    if (pre[i]) printf("%d %d\n", pre[i], i);
  return 0;
}