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;
int a[30005][205], n, b[205], m;
vector<int> edge[30005];
struct union_find {
  int par[30005], ran[30005];
  void init() {
    for (int i = 0; i < 30005; i++) par[i] = i;
  }
  int find(int x) {
    if (x == par[x])
      return x;
    else
      return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (ran[x] < ran[y])
      par[x] = y;
    else {
      par[y] = x;
      if (ran[x] == ran[y]) ran[x]++;
    }
  }
  bool same(int x, int y) { return find(x) == find(y); }
} uf;
int num[30005];
bool used[30005];
long long pr = 17, pr2 = 33;
long long hashh[30005][2], hashh_one[30005][2];
map<pair<long long, long long>, int> M;
bool dfs(int v, int u, int d, int num) {
  if (a[v][num] != d) return 1;
  for (int i = 0; i < edge[v].size(); i++) {
    if (edge[v][i] == u) continue;
    if (dfs(edge[v][i], v, d + 1, num)) return 1;
  }
  return 0;
}
int main() {
  cin >> n >> m;
  uf.init();
  for (int j = 1; j <= m; j++)
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i][j]);
      if (a[i][j] == 0) {
        if (b[j] != 0) {
          puts("-1");
          return 0;
        }
        b[j] = i;
      }
    }
  for (int i = 1; i <= n; i++) {
    long long cur = pr, cur2 = pr2;
    for (int j = 1; j <= m; j++) {
      hashh[i][0] += a[i][j] * cur % 1000000007;
      hashh_one[i][0] += (a[i][j] - 1) * cur % 1000000007;
      hashh[i][1] += a[i][j] * cur2 % 1000000007;
      hashh_one[i][1] += (a[i][j] - 1) * cur2 % 1000000007;
      cur = cur * pr % 1000000007;
      cur2 = cur2 * pr2 % 1000000007;
    }
    for (int k = 0; k < 2; k++) {
      hashh[i][k] = (hashh[i][k] % 1000000007 + 1000000007) % 1000000007;
      hashh_one[i][k] =
          (hashh_one[i][k] % 1000000007 + 1000000007) % 1000000007;
    }
    M[make_pair(hashh[i][0], hashh[i][1])] = i;
  }
  for (int j = 1; j <= m; j++)
    if (b[j] == 0) {
      puts("-1");
      return 0;
    }
  for (int j = 2; j <= m; j++) {
    int D = 1000000000;
    for (int i = 1; i <= n; i++) {
      D = min(D, a[i][1] + a[i][j]);
    }
    for (int i = 0; i <= D; i++) num[i] = 0;
    for (int i = 1; i <= n; i++) {
      if (a[i][1] + a[i][j] == D) {
        if (num[a[i][1]] != 0) {
          puts("-1");
          return 0;
        }
        num[a[i][1]] = i;
      }
    }
    for (int i = 0; i <= D; i++)
      if (num[i] == 0) {
        puts("-1");
        return 0;
      }
    for (int i = 0; i < D; i++) {
      if (!uf.same(num[i], num[i + 1])) {
        edge[num[i]].push_back(num[i + 1]);
        edge[num[i + 1]].push_back(num[i]);
        uf.unite(num[i], num[i + 1]);
      }
      used[num[i]] = 1;
      used[num[i + 1]] = 1;
    }
  }
  for (int i = 1; i <= m; i++) used[b[i]] = 1;
  for (int i = 1; i <= m; i++) {
    if (uf.find(b[1]) != uf.find(b[i])) {
      puts("-1");
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (used[i]) continue;
    if (M.find(make_pair(hashh_one[i][0], hashh_one[i][1])) == M.end()) {
      puts("-1");
      return 0;
    }
    int x = M[make_pair(hashh_one[i][0], hashh_one[i][1])];
    if (uf.same(i, x)) {
      puts("-1");
      return 0;
    }
    edge[i].push_back(x);
    edge[x].push_back(i);
    uf.unite(i, x);
  }
  for (int i = 1; i <= n; i++)
    if (!uf.same(1, i)) {
      puts("-1");
      return 0;
    }
  for (int i = 1; i <= m; i++) {
    bool flag = dfs(b[i], -1, 0, i);
    if (flag) {
      puts("-1");
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < edge[i].size(); j++) {
      if (i < edge[i][j]) {
        printf("%d %d\n", i, edge[i][j]);
      }
    }
  }
  return 0;
}