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 mod = 1e9 + 7;
using namespace std;
int n, k, dis[211][100010], id[211], vis[100010];
int fa[100010];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%d", &dis[i][j]);
      if (!dis[i][j]) {
        if (id[i])
          return puts("-1"), 0;
        else
          id[i] = j;
      }
    }
    if (!id[i]) return puts("-1"), 0;
    if (vis[id[i]]) return puts("-1"), 0;
    vis[id[i]] = 1;
  }
  int rt = id[1];
  vector<int> ps[k + 1];
  for (int i = 1; i <= k; i++) ps[i] = vector<int>();
  for (int t = 2; t <= k; t++) {
    int v = id[t];
    vector<int> par(n + 1, -1);
    for (int u = 1; u <= n; u++) {
      if (dis[t][u] + dis[1][u] == dis[1][v]) {
        if (par[dis[1][u]] != -1) return puts("-1"), 0;
        par[dis[1][u]] = u;
      }
    }
    for (int i = 0; i < n; i++) {
      if (par[i] == -1 && i <= dis[1][v]) return puts("-1"), 0;
      if (par[i] != -1 && i > dis[1][v]) return puts("-1"), 0;
    }
    for (int i = 0; i < dis[1][v]; i++) {
      int p = par[i], u = par[i + 1];
      if (fa[u] != 0 && fa[u] != p) return puts("-1"), 0;
      fa[u] = p;
    }
    ps[t] = par;
  }
  if (fa[rt] != 0) return puts("-1"), 0;
  vector<int> subs[n + 1];
  for (int i = 0; i <= n; i++) subs[i] = vector<int>();
  vector<int> vh[n + 1];
  for (int i = 0; i <= n; i++) vh[i] = vector<int>();
  for (int i = 1; i <= n; i++) vh[dis[1][i]].push_back(i);
  for (int h = 0; h < n; h++) {
    for (int v : vh[h]) {
      if (v == rt || fa[v] != 0) continue;
      int lp = rt, lt = 1;
      for (int t = 2; t <= k; t++) {
        int u = id[t];
        int hl2 = dis[1][u] + dis[1][v] - dis[t][v];
        if (hl2 & 1) return puts("-1"), 0;
        int hl = hl2 / 2;
        if (hl < 0 || hl > dis[1][u] || hl > dis[1][v]) return puts("-1"), 0;
        int l = ps[t][hl];
        if (dis[1][l] >= dis[1][lp]) {
          if (ps[t][dis[1][lp]] != lp) return puts("-1"), 0;
          lp = l;
          lt = t;
        } else {
          if (ps[lt][dis[1][l]] != l) return puts("-1"), 0;
        }
      }
      subs[lp].push_back(v);
    }
  }
  for (int i = 1; i <= n; i++) {
    int pre = i, nxt = -1;
    for (int v : subs[i]) {
      if (dis[1][v] == dis[1][pre] + 1) {
        fa[v] = pre;
        nxt = v;
      } else {
        pre = nxt;
        if (pre != -1 && dis[1][v] == dis[1][pre] + 1) {
          fa[v] = pre;
          nxt = v;
        } else
          return puts("-1"), 0;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (i == rt)
      continue;
    else
      printf("%d %d\n", i, fa[i]);
  }
  return 0;
}