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 MN = 3e4 + 5, MM = 202, mod = 1e9 + 7;
int N, K, i, j, x, y, c, f, w, arr[MN][MM], id[MN], hsh[MN], cc[MN][MM];
map<int, vector<int> > mp;
vector<pair<int, int> > ans;
vector<int> res;
int hs(vector<int> vec) {
  int r = 1;
  for (auto v : vec) r = (1LL * r * (N + 1) + v) % mod;
  return r;
}
int main() {
  for (scanf("%d%d", &N, &K), i = 1; i <= K; i++) {
    w = 0;
    for (j = 1; j <= N; j++) {
      scanf("%d", &arr[j][i]);
      if (!arr[j][i]) w++, f = i;
    }
    if (w != 1) return !printf("-1\n");
  }
  for (i = 1; i <= N; i++) {
    hsh[i] = 1;
    for (j = 1; j <= K; j++)
      hsh[i] = (1LL * hsh[i] * (N + 1) + arr[i][j]) % mod;
    id[i] = i;
  }
  if (!f) return !printf("-1\n");
  sort(id + 1, id + N + 1, [](int i, int j) { return arr[i][f] > arr[j][f]; });
  for (i = 1; i <= N; i++) {
    if (mp.count(hsh[id[i]])) {
      vector<int> wh = mp[hsh[id[i]]];
      for (auto v : wh) {
        ans.push_back({v, id[i]}), c++;
        for (j = 1; j <= K; j++) cc[id[i]][j] |= cc[v][j];
      }
      mp.erase(hsh[id[i]]);
    }
    for (j = 1; j <= K; j++)
      if (!arr[id[i]][j]) cc[id[i]][j] = 1;
    res.clear();
    for (j = 1; j <= K; j++) {
      if (cc[id[i]][j])
        res.push_back(arr[id[i]][j] + 1);
      else
        res.push_back(arr[id[i]][j] - 1);
    }
    int hh = hs(res);
    if (!mp.count(hh)) mp[hh] = vector<int>();
    mp[hh].push_back(id[i]);
  }
  if (c != N - 1)
    printf("-1\n");
  else
    for (auto v : ans) printf("%d %d\n", v.first, v.second);
  return 0;
}