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 K = 202;
const int N = 3e4 + 2;
const int inf = 1e9 + 7;
int dis[K][N], idx[K], par[N];
int ver[K][N];
pair<int, int> lst[N], lis[N];
bool used[N];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, num, i, j, k, l, cnt = 0;
  cin >> n >> num;
  for (i = 1; i <= num; i++) {
    for (j = 1; j <= n; j++) {
      cin >> dis[i][j];
      if (dis[i][j] == 0) {
        if (!idx[i]) {
          idx[i] = j;
        } else {
          cout << -1;
          return 0;
        }
      }
    }
    if (!idx[i]) {
      cout << -1;
      return 0;
    }
    used[idx[i]] = true;
    lst[idx[i]].first = idx[i];
    lst[idx[i]].second = dis[1][idx[i]];
  }
  for (i = 1; i <= num; i++) {
    for (j = i + 1; j <= num; j++) {
      if (dis[i][idx[j]] != dis[j][idx[i]]) {
        cout << -1;
        return 0;
      }
      if (idx[i] == idx[j]) {
        cout << -1;
        return 0;
      }
    }
  }
  ver[1][0] = idx[1];
  int root = idx[1];
  for (i = 2; i <= num; i++) {
    for (j = 1; j <= n; j++) {
      if (dis[1][j] + dis[i][j] == dis[1][idx[i]]) {
        if (!ver[i][dis[1][j]]) {
          ver[i][dis[1][j]] = j;
        } else {
          cout << -1;
          return 0;
        }
      }
    }
    for (j = 0; j <= dis[1][idx[i]]; j++) {
      if (!ver[i][j]) {
        cout << -1;
        return 0;
      }
      if (j) {
        if (!par[ver[i][j]]) {
          par[ver[i][j]] = ver[i][j - 1];
        } else {
          if (par[ver[i][j]] != ver[i][j - 1]) {
            cout << -1;
            return 0;
          }
        }
      }
      lst[ver[i][j]].first = ver[i][j];
      lst[ver[i][j]].second = dis[1][ver[i][j]];
      used[ver[i][j]] = true;
    }
  }
  for (i = 1; i <= n; i++) {
    if (!used[i]) {
      cnt++;
      lis[cnt].first = dis[1][i];
      lis[cnt].second = i;
    }
  }
  sort(lis + 1, lis + 1 + cnt);
  i = j = 1;
  while (i <= cnt) {
    while (j <= cnt && lis[i].first == lis[j].first) {
      j++;
    }
    for (k = i; k < j; k++) {
      int u = lis[k].second;
      int lca = idx[1];
      for (l = 1; l <= num; l++) {
        int wow = (dis[1][idx[l]] + dis[1][u] - dis[l][u]) / 2;
        int v = ver[l][wow];
        if (dis[1][lca] < dis[1][v]) {
          lca = v;
        }
      }
      if (lst[lca].second + 1 != dis[1][u]) {
        cout << -1;
        return 0;
      }
      par[u] = lst[lca].first;
    }
    for (k = i; k < j; k++) {
      int u = lis[k].second;
      int lca = idx[1];
      for (l = 1; l <= num; l++) {
        int wow = (dis[1][idx[l]] + dis[1][u] - dis[l][u]) / 2;
        int v = ver[l][wow];
        if (dis[1][lca] < dis[1][v]) {
          lca = v;
        }
      }
      lst[lca].second = dis[1][u];
      lst[lca].first = u;
    }
    i = j;
  }
  for (i = 1; i <= n; i++) {
    if (i == idx[1]) {
      continue;
    }
    cout << par[i] << ' ' << i << '\n';
  }
}