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 oo = 0x3f3f3f3f;
const long long ooo = 9223372036854775807ll;
const int _cnt = 1000 * 1000 + 7;
const int _p = 1000 * 1000 * 1000 + 7;
const int N = 200105;
const double PI = acos(-1.0);
const double eps = 1e-6;
int o(int x) { return x % _p; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
void file_put() {
  freopen("filename.in", "r", stdin);
  freopen("filename.out", "w", stdout);
}
int n, m, k, d[205][30015], p[205][30015], pre[30015], id[205], dd[30015], mx,
    t, tt;
bool v[30015];
vector<int> V[30015];
bool cmp(int x, int y) { return dd[x] < dd[y]; }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (1); i <= (m); ++i)
    for (int j = (1); j <= (n); ++j) {
      scanf("%d", &d[i][j]);
      if (!d[i][j])
        if (!id[i])
          id[i] = j;
        else
          return 0 * puts("-1");
    }
  for (int i = (1); i <= (m); ++i)
    if (!id[i]) return 0 * puts("-1");
  for (int i = (1); i <= (n); ++i) dd[i] = d[1][i];
  p[1][0] = id[1], v[id[1]] = 1;
  for (int i = (2); i <= (m); ++i) {
    for (int j = (1); j <= (n); ++j)
      if (dd[j] + d[i][j] == dd[id[i]]) p[i][dd[j]] = j, v[j] = 1;
    for (int j = (1); j <= (dd[id[i]]); ++j) {
      if (!p[i][j]) return 0 * puts("-1");
      pre[p[i][j]] = p[i][j - 1];
    }
  }
  for (int i = (1); i <= (n); ++i)
    if (!v[i]) {
      mx = -oo;
      for (int j = (1); j <= (m); ++j) {
        t = dd[i] + dd[id[j]] - d[j][i] >> 1;
        if (t > mx) mx = t, tt = p[j][t];
      }
      V[tt].push_back(i);
    }
  for (int i = (1); i <= (n); ++i)
    if (v[i]) {
      sort((V[i]).begin(), (V[i]).end(), cmp);
      t = i;
      for (int j = (0); j <= ((int)V[i].size() - 1); ++j) {
        if (j && dd[V[i][j]] != dd[V[i][j - 1]]) t = V[i][j - 1];
        if (dd[V[i][j]] != dd[t] + 1) return 0 * puts("-1");
        pre[V[i][j]] = t;
      }
    }
  for (int i = (1); i <= (n); ++i)
    if (i != id[1]) printf("%d %d\n", i, pre[i]);
  return 0;
}