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 bad() {
  cout << "-1\n";
  exit(0);
}
const int maxn = 3e4 + 79, maxk = 2e2 + 79;
vector<vector<int> > d(maxk, vector<int>(maxn)), g(maxn), path(maxk), v(maxn);
vector<int> p(maxn, -1), mark(maxn, 0), s;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < n; j++) cin >> d[i][j];
    if (count(d[i].begin(), d[i].begin() + n, 0) != 1) bad();
    s.push_back(min_element(d[i].begin(), d[i].begin() + n) - d[i].begin());
    if (count(s.begin(), s.end(), s.back()) > 1) bad();
  }
  mark[s[0]] = true;
  path[0].push_back(s[0]);
  for (int i = 1; i < k; i++) {
    vector<pair<int, int> > tmppath;
    for (int j = 0; j < n; j++)
      if (d[0][j] + d[i][j] == d[0][s[i]]) tmppath.push_back({d[0][j], j});
    sort(tmppath.begin(), tmppath.end());
    if (d[0][s[i]] + 1 != tmppath.size()) bad();
    for (pair<int, int> j : tmppath) path[i].push_back(j.second);
    if (count(path[i].begin(), path[i].end(), -1)) bad();
    for (int j = 1; j < path[i].size(); j++) {
      if (d[0][path[i][j - 1]] + 1 != d[0][path[i][j]] ||
          (p[path[i][j]] != -1 && p[path[i][j]] != path[i][j - 1]))
        bad();
      p[path[i][j]] = path[i][j - 1];
      g[path[i][j - 1]].push_back(path[i][j]);
      mark[path[i][j]] = true;
    }
  }
  vector<pair<int, int> > lf;
  for (int i = 0; i < n; i++)
    if (!mark[i])
      lf.push_back({d[0][i], i});
    else
      v[i].push_back(i);
  sort(lf.begin(), lf.end());
  for (pair<int, int> i : lf) {
    int u = i.second;
    pair<int, int> pv = {-1, -1};
    for (int j = 0; j < s.size(); j++) {
      int depth_lca = d[0][s[j]] + d[0][u] - d[j][u];
      if (depth_lca & 1) bad();
      depth_lca /= 2;
      pv = max(pv, make_pair(depth_lca, path[j][depth_lca]));
    }
    v[pv.second].push_back(u);
  }
  for (int i = 0; i < n; i++) {
    int pv = -1;
    for (int j = 1; j < v[i].size(); j++) {
      if (d[0][v[i][j - 1]] < d[0][v[i][j]]) pv = v[i][j - 1];
      if (pv == -1 || d[0][pv] + 1 != d[0][v[i][j]]) bad();
      p[v[i][j]] = pv;
    }
  }
  for (int i = 0; i < n; i++) {
    if (p[i] != -1) cout << i + 1 << " " << p[i] + 1 << "\n";
  }
  return 0;
}