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;
template <typename T1, typename T2>
inline T1 max(T1 a, T2 b) {
  return a < b ? b : a;
}
template <typename T1, typename T2>
inline T1 min(T1 a, T2 b) {
  return a < b ? a : b;
}
const char lf = '\n';
namespace ae86 {
const int bufl = 1 << 15;
char buf[bufl], *s = buf, *t = buf;
inline int fetch() {
  if (s == t) {
    t = (s = buf) + fread(buf, 1, bufl, stdin);
    if (s == t) return EOF;
  }
  return *s++;
}
inline int ty() {
  int a = 0;
  int b = 1, c = fetch();
  while (!isdigit(c)) b ^= c == '-', c = fetch();
  while (isdigit(c)) a = a * 10 + c - 48, c = fetch();
  return b ? a : -a;
}
}  // namespace ae86
using ae86::ty;
const int _ = 207, __ = 30007;
inline void failure() {
  cout << -1 << lf;
  exit(0);
}
int n, m, loc[_] = {0}, dis[_][__] = {0}, ps[_][__] = {0}, ed[__] = {0},
          las[__] = {0};
vector<pair<int, int>> has[__];
int main() {
  ios::sync_with_stdio(0), cout.tie(nullptr);
  n = ty(), m = ty();
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      dis[i][j] = ty();
      if (!dis[i][j]) loc[i] = j;
    }
    if (!loc[i]) failure();
  }
  for (int i = 2; i <= m; i++) {
    for (int j = 1; j <= n; j++)
      if (dis[1][j] + dis[i][j] == dis[1][loc[i]])
        ps[i][dis[1][j]] = j, ed[j] = 1;
    for (int j = dis[1][loc[i]]; j >= 1; j--) {
      if (!ps[i][j]) failure();
      las[ps[i][j]] = ps[i][j - 1];
    }
  }
  ed[loc[1]] = 1;
  for (int i = 1; i <= n; i++) {
    if (ed[i]) continue;
    int mx = 0, mxloc = loc[1];
    for (int j = 2; j <= m; j++) {
      int a = (dis[1][loc[j]] + dis[1][i] - dis[j][i]) >> 1;
      if (a >= mx) mx = a, mxloc = ps[j][a];
    }
    has[mxloc].emplace_back(dis[1][i], i);
  }
  for (int j = 1; j <= n; j++) {
    sort(has[j].begin(), has[j].end());
    for (int i = 0, pre = dis[1][j], now = j; i < ((int)((has[j]).size()));) {
      pre++;
      if (pre != has[j][i].first) failure();
      while (i < ((int)((has[j]).size())) - 1 && has[j][i + 1].first == pre)
        las[has[j][i].second] = now, i++;
      las[has[j][i].second] = now, now = has[j][i].second, i++;
    }
  }
  for (int i = 1; i <= n; i++)
    if (las[i]) cout << las[i] << ' ' << i << lf;
  return 0;
}