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 M1 = 998244353, M2 = 1e9 + 7;
std::map<int, bool> E[30010];
int n, k, d[210][30010], M[210], *m[210], b[30010], D1[30010], D2[30010];
bool vis[30010];
struct Hash {
  int Point[19260817], Next[30010], q, H1[30010], H2[30010], f[30010];
  void Add(int h1, int h2, int p) {
    int t = (h1 ^ h2) % 19260817;
    for (int j = Point[t]; j; j = Next[j])
      if (H1[j] == h1 && H2[j] == h2) return;
    Next[++q] = Point[t];
    Point[t] = q;
    H1[q] = h1;
    H2[q] = h2;
    f[q] = p;
  }
  int find(int h1, int h2) {
    int t = (h1 ^ h2) % 19260817;
    for (int j = Point[t]; j; j = Next[j])
      if (H1[j] == h1 && H2[j] == h2) return f[j];
    return 0;
  }
} H;
bool cmp(const int *i, const int *j) { return d[1][*i] < d[1][*j]; }
bool cmp1(const int &i, const int &j) { return d[1][i] < d[1][j]; }
struct pair {
  int u, v;
} Ans[30010];
int tot;
void Add(int u, int v) { Ans[++tot] = (pair){u, v}; }
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; ++i) D1[i] = rand();
  for (int i = 1; i <= n; ++i) D2[i] = rand();
  for (int i = 1; i <= k; ++i) {
    for (int j = 1; j <= n; ++j) {
      scanf("%d", &d[i][j]);
      if (!d[i][j]) {
        {
          if (M[i]) {
            puts("-1");
            return 0;
          }
        };
        M[i] = j;
      }
    }
    {
      if (!M[i]) {
        puts("-1");
        return 0;
      }
    };
  }
  for (int i = 2; i <= k; ++i) m[i] = M + i;
  std::sort(m + 2, m + k + 1, cmp);
  for (int i = 1; i <= n; ++i) b[i] = i;
  std::sort(b + 1, b + n + 1, cmp1);
  vis[M[1]] = 1;
  for (int i = 2; i <= k; ++i) {
    int now = M[1], dis = d[1][*m[i]];
    for (int *j = b + 2; j <= b + n && now != *m[i]; ++j) {
      if (d[m[i] - M][*j] + d[1][*j] == dis) {
        if (!E[now][*j]) {
          Add(now, *j);
          E[now][*j] = 1;
          vis[*j] = 1;
        }
        now = *j;
      }
    }
    {
      if (now != *m[i]) {
        puts("-1");
        return 0;
      }
    };
  }
  for (int i = 1; i <= n; ++i)
    if (vis[i]) {
      int h1 = 0, h2 = 0;
      for (int j = 1; j <= k; ++j)
        h1 = (1ll * h1 * 137 + 1ll * D1[j] * d[j][i]) % M1;
      for (int j = 1; j <= k; ++j)
        h2 = (1ll * h2 * 117 + 1ll * D2[j] * d[j][i]) % M2;
      H.Add(h1, h2, i);
    }
  for (int *i = b + 1; i <= b + n; ++i)
    if (!vis[*i]) {
      int h1 = 0, h2 = 0, pos;
      for (int j = 1; j <= k; ++j)
        h1 = (1ll * h1 * 137 + 1ll * D1[j] * (d[j][*i] - 1)) % M1;
      for (int j = 1; j <= k; ++j)
        h2 = (1ll * h2 * 117 + 1ll * D2[j] * (d[j][*i] - 1)) % M2;
      {
        if (!(pos = H.find(h1, h2))) {
          puts("-1");
          return 0;
        }
      };
      Add(pos, *i);
      h1 = h2 = 0;
      for (int j = 1; j <= k; ++j)
        h1 = (1ll * h1 * 137 + 1ll * D1[j] * d[j][*i]) % M1;
      for (int j = 1; j <= k; ++j)
        h2 = (1ll * h2 * 117 + 1ll * D2[j] * d[j][*i]) % M2;
      H.Add(h1, h2, *i);
    }
  for (pair *i = Ans + 1; i < Ans + n; ++i) printf("%d %d\n", i->u, i->v);
  return 0;
}