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;
inline int Read() {
  int x = 0, f = 1, c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
const int MAXN = 30005;
const int MAXM = 205;
int n, m, idx[MAXN], par[MAXN], p[MAXM][MAXN], d[MAXM][MAXN];
vector<int> adj[MAXN];
vector<pair<int, int> > sub[MAXN];
bool v[MAXN];
inline void GG() {
  puts("-1");
  exit(0);
}
inline void Dfs(int x, int *d, int dep, int p) {
  if (dep ^ d[x]) GG();
  for (auto y : adj[x])
    if (y ^ p) Dfs(y, d, dep + 1, x);
}
int main() {
  n = Read(), m = Read();
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++)
      if (!(d[i][j] = Read())) {
        if (idx[i]) GG();
        idx[i] = j;
      }
    if (!idx[i]) GG();
  }
  p[1][0] = idx[1], v[idx[1]] = true;
  for (int i = 2; i <= m; i++) {
    for (int j = 1; j <= n; j++)
      if (d[1][j] + d[i][j] == d[1][idx[i]]) {
        if (p[i][d[1][j]]) GG();
        p[i][d[1][j]] = j, v[j] = true;
      }
    for (int j = 1; j <= d[1][idx[i]]; j++) {
      if (!p[i][j]) GG();
      if (par[p[i][j]] && par[p[i][j]] != p[i][j - 1]) GG();
      par[p[i][j]] = p[i][j - 1];
    }
  }
  for (int i = 1; i <= n; i++)
    if (!v[i]) {
      int x = -1, pos = 0;
      for (int j = 1; j <= m; j++) {
        int dis = d[1][i] + d[1][idx[j]] - d[j][i] >> 1;
        if (x < dis) x = dis, pos = p[j][dis];
      }
      sub[pos].push_back(make_pair(d[1][i], i));
    }
  for (int i = 1; i <= n; i++) {
    sort(sub[i].begin(), sub[i].end());
    for (int j = 0, dep = d[1][i], lst = i; j < sub[i].size(); j++) {
      if (j && (sub[i][j].first ^ sub[i][j - 1].first))
        lst = sub[i][j - 1].second, dep = d[1][lst];
      if (sub[i][j].first - dep - 1) GG();
      par[sub[i][j].second] = lst;
    }
  }
  for (int i = 1; i <= n; i++)
    if (par[i])
      adj[par[i]].push_back(i), adj[i].push_back(par[i]);
    else if (i ^ idx[1])
      GG();
  for (int i = 1; i <= m; i++) Dfs(idx[i], d[i], 0, 0);
  for (int x = 1; x <= n; x++)
    if (par[x]) printf("%d %d\n", x, par[x]);
  return 0;
}