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 T, typename U>
inline void smin(T &a, const U &b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, const U &b) {
  if (a < b) a = b;
}
template <class T>
inline void gn(T &first) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9';
       c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
}
template <class T1, class T2>
inline void gn(T1 &x1, T2 &x2) {
  gn(x1), gn(x2);
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
void bye() {
  puts("-1");
  exit(0);
}
int n, m;
vector<int> adj[30030], con[30030];
int d[210][30030];
int f[210][30030];
int id[210];
int p[30030];
void dfs(int u, int num, int f = 0, int dp = 0) {
  if (d[num][u] != dp) bye();
  for (int v : adj[u]) {
    if (v == f) continue;
    dfs(v, num, u, dp + 1);
  }
}
void check() {
  for (int i = 1; i <= m; i++) dfs(id[i], i);
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      gn(d[i][j]);
      if (!d[i][j]) {
        if (id[i]) bye();
        id[i] = j;
      }
    }
    if (!id[i]) bye();
  }
  for (int i = 1; i <= m; i++)
    for (int j = 1; j < i; j++) {
      if (id[i] == id[j]) bye();
      if (d[i][id[j]] != d[j][id[i]]) bye();
    }
  for (int i = 2; i <= m; i++) {
    for (int j = 1; j <= n; j++)
      if (d[1][j] + d[i][j] == d[1][id[i]]) {
        if (f[i][d[i][j]]) bye();
        f[i][d[i][j]] = j;
      }
    for (int j = 0; j < d[i][id[1]]; j++)
      if (!f[i][j]) bye();
    for (int j = 0; j < d[i][id[1]]; j++) {
      if (p[f[i][j]] && p[f[i][j]] != f[i][j + 1]) bye();
      p[f[i][j]] = f[i][j + 1];
    }
  }
  for (int i = 1; i <= n; i++)
    if (p[i]) adj[i].push_back(p[i]), adj[p[i]].push_back(i);
  check();
  vector<int> rem;
  for (int i = 1; i <= n; i++) {
    if (p[i] || i == id[1])
      con[i].push_back(i);
    else
      rem.push_back(i);
  }
  if (!rem.empty()) {
    sort(rem.begin(), rem.end(),
         [](int a, int b) { return d[1][a] < d[1][b]; });
    for (int first : rem) {
      int now = id[1];
      for (int i = 2; i <= m; i++) {
        int l = d[i][first] + d[1][first] - d[1][id[i]];
        if (l <= 0 || (l & 1)) bye();
        int nxt = f[i][d[i][first] - l / 2];
        if (d[1][now] < d[1][nxt]) now = nxt;
      }
      int dp = d[1][first] - d[1][now];
      if (con[now].size() >= dp) {
        adj[con[now][dp - 1]].push_back(first);
        adj[first].push_back(con[now][dp - 1]);
        if (dp == con[now].size()) con[now].push_back(first);
      } else
        bye();
    }
    check();
  }
  for (int i = 1; i <= n; i++)
    for (int j : adj[i])
      if (j > i) printf("%d %d\n", i, j);
  return 0;
}