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;
void impossible() {
  puts("-1");
  exit(0);
}
int main() {
  int n, k;
  assert(scanf("%d %d", &n, &k) == 2);
  assert(k > 0);
  vector<int> dist[k];
  vector<int> idx(n, 0);
  for (int i = 0; i < k; ++i) {
    dist[i] = vector<int>(n, 0);
    for (int j = 0; j < n; ++j) assert(scanf("%d", &dist[i][j]) == 1);
    idx[i] = -1;
    for (int j = 0; j < n; ++j) {
      if (dist[i][j] == 0) {
        if (idx[i] != -1)
          impossible();
        else
          idx[i] = j;
      }
    }
    if (idx[i] == -1) impossible();
    for (int j = 0; j < i; ++j)
      if (idx[i] == idx[j]) impossible();
  }
  vector<int> p(n, -1);
  vector<int> h = dist[0];
  int root = idx[0];
  vector<int> ps[k];
  for (int i = 0; i < k; ++i) ps[i] = vector<int>();
  for (int t = 1; t < k; ++t) {
    int v = idx[t];
    vector<int> &d = dist[t];
    vector<int> pars(n, -1);
    for (int u = 0; u < n; ++u) {
      if (h[u] + d[u] == h[v]) {
        if (pars[h[u]] != -1) impossible();
        pars[h[u]] = u;
      }
    }
    for (int i = 0; i < n; ++i) {
      if (pars[i] == -1 && i <= h[v]) impossible();
      if (pars[i] != -1 && i > h[v]) impossible();
    }
    for (int i = 0; i < h[v]; ++i) {
      int pu = pars[i];
      int u = pars[i + 1];
      if (p[u] != -1 && p[u] != pu) impossible();
      p[u] = pu;
    }
    ps[t] = pars;
  }
  if (p[root] != -1) impossible();
  vector<int> subs[n];
  for (int i = 0; i < n; ++i) subs[i] = vector<int>();
  vector<int> vh[n];
  for (int i = 0; i < n; ++i) vh[i] = vector<int>();
  for (int v = 0; v < n; ++v) vh[h[v]].push_back(v);
  for (int hh = 0; hh < n; ++hh) {
    for (int v : vh[hh]) {
      if (v == root || p[v] != -1) continue;
      int lp = root;
      int lt = 0;
      for (int t = 1; t < k; ++t) {
        int u = idx[t];
        vector<int> &d = dist[t];
        vector<int> &pars = ps[t];
        int hl2 = h[v] + h[u] - d[v];
        if (hl2 % 2 != 0) impossible();
        int hl = hl2 / 2;
        if (hl < 0 || hl > h[u] || hl > h[v]) impossible();
        int l = pars[hl];
        if (h[l] >= h[lp]) {
          if (pars[h[lp]] != lp) impossible();
          lp = l;
          lt = t;
        } else {
          if (ps[lt][h[l]] != l) impossible();
        }
      }
      subs[lp].push_back(v);
    }
  }
  for (int i = 0; i < n; ++i) {
    int prev = i;
    int nxt = -1;
    for (int v : subs[i]) {
      assert(prev != -1);
      if (h[v] == h[prev] + 1) {
        p[v] = prev;
        nxt = v;
      } else {
        prev = nxt;
        if (prev != -1 && h[v] == h[prev] + 1) {
          p[v] = prev;
          nxt = v;
        } else
          impossible();
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if (i == root)
      assert(p[i] == -1);
    else {
      printf("%d %d\n", i + 1, p[i] + 1);
    }
  }
  return 0;
}