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 = 30010, K = 210;
const unsigned long long base1 = 398989, base2 = 1145141;
vector<int> v[N];
map<int, bool> E[N];
map<pair<unsigned long long, unsigned long long>, int> ma;
int n, k, ans[N][2], tmp[N], key[K], rt, vis[N], gcnt;
pair<int, int> a[N];
void add(int x, int y) {
  E[x][y] = 1, E[y][x] = 1;
  ans[++gcnt][0] = x, ans[gcnt][1] = y;
  vis[x] = vis[y] = 1;
}
int main() {
  int i, j, k, x, y, z;
  unsigned long long h1, h2;
  scanf("%d%d", &n, &k);
  for (i = 1; i <= n; i++) v[i].push_back(0);
  for (i = 1; i <= k; i++) {
    for (j = 1; j <= n; j++) scanf("%d", &tmp[j]);
    for (j = 1; j <= n; j++)
      if (tmp[j] == 0) break;
    if (j == n + 1) cout << -1, exit(0);
    x = j;
    for (j = j + 1; j <= n; j++)
      if (tmp[j] == 0) cout << -1, exit(0);
    key[i] = x;
    for (j = 1; j <= n; j++) v[x].push_back(tmp[j]);
  }
  rt = key[1];
  for (i = 1; i <= n; i++) a[i] = make_pair(v[rt][i], i);
  sort(a + 1, a + n + 1);
  vis[rt] = 1;
  for (i = 2; i <= k; i++) {
    x = rt;
    for (j = 2; j <= n; j++) {
      y = a[j].second;
      if (a[j].first + v[key[i]][y] == v[rt][key[i]]) {
        if (!E[x][y]) add(x, y);
        x = y;
      }
    }
  }
  for (i = 1; i <= n; i++) {
    if (!vis[i]) continue;
    h1 = h2 = 0;
    for (j = 1; j <= k; j++) h1 = h1 * base1 + v[key[j]][i];
    for (j = 1; j <= k; j++) h2 = h2 * base2 + v[key[j]][i];
    ma[make_pair(h1, h2)] = i;
  }
  for (i = 2; i <= n; i++) {
    x = a[i].second;
    if (vis[x]) continue;
    h1 = h2 = 0;
    for (j = 1; j <= k; j++) h1 = h1 * base1 + v[key[j]][x] - 1;
    for (j = 1; j <= k; j++) h2 = h2 * base2 + v[key[j]][x] - 1;
    if (ma.find(make_pair(h1, h2)) == ma.end()) cout << -1, exit(0);
    add(ma[make_pair(h1, h2)], x);
    h1 = h2 = 0;
    for (j = 1; j <= k; j++) h1 = h1 * base1 + v[key[j]][x];
    for (j = 1; j <= k; j++) h2 = h2 * base2 + v[key[j]][x];
    ma[make_pair(h1, h2)] = x;
  }
  for (i = 1; i < n; i++) printf("%d %d\n", ans[i][0], ans[i][1]);
  return ~~(0 - 0);
}