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;
const int N = 30100, M = 210;
int a[M][N], b[M], vis[N], fa[N], pt[M][N], n, K;
vector<pair<int, int> > vec[N];
void gofail() {
  cout << -1 << '\n';
  exit(0);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> K;
  for (int i = 1; i <= K; ++i) {
    for (int j = 1; j <= n; ++j) {
      cin >> a[i][j];
      if (!a[i][j]) b[i] = j;
    }
    if (!b[i] || a[1][b[i]] != a[i][b[1]]) gofail();
    for (int j = 1; j <= n; ++j) {
      if ((a[1][j] + a[i][j] - a[1][b[i]]) & 1) gofail();
      if (a[1][j] + a[i][j] == a[1][b[i]]) vis[j] = 1, pt[i][a[1][j]] = j;
    }
    for (int j = 1; j <= a[1][b[i]]; ++j) {
      if (!pt[i][j]) gofail();
      fa[pt[i][j]] = pt[i][j - 1];
    }
  }
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) {
      int tp = b[1], mx = 0;
      for (int j = 1; j <= K; ++j) {
        int res = (a[1][b[j]] + a[1][i] - a[j][i]) / 2;
        if (res < 0 || res > a[1][b[j]]) gofail();
        if (res > mx) mx = res, tp = pt[j][res];
      }
      vec[tp].emplace_back(a[1][i], i);
    }
  for (int i = 1; i <= n; ++i) {
    sort(vec[i].begin(), vec[i].end());
    int lst = i, npt = i, ldp = a[1][i] + 1;
    for (auto j : vec[i]) {
      if (ldp + 1 < j.first || ldp > j.first) gofail();
      if (ldp < j.first) lst = npt, ldp = j.first;
      fa[npt = j.second] = lst;
    }
  }
  for (int i = 1; i <= n; ++i)
    if (i != b[1]) {
      int u = i, v = fa[i];
      if (u > v) swap(u, v);
      vec[0].emplace_back(u, v);
    }
  sort(vec[0].begin(), vec[0].end());
  for (auto i : vec[0]) cout << i.first << ' ' << i.second << '\n';
  return 0;
}