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 long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
const int N = 30100;
int rtp[N], rt[N], f[N], d[210][N], ord[N];
vector<int> prt;
int n, k;
map<vector<int>, int> hs;
vector<int> vec[N], e[N];
set<pair<int, int> > E;
set<int> ins;
void fuck(bool op) {
  if (op == 0) {
    puts("-1");
    exit(0);
  }
}
int find(int u) { return f[u] == u ? u : f[u] = find(f[u]); }
void add(int u, int v) {
  if (u > v) swap(u, v);
  if (E.count(make_pair(u + 1, v + 1))) return;
  fuck(find(u) != find(v));
  f[find(u)] = find(v);
  E.insert(make_pair(u + 1, v + 1));
  e[u].push_back(v);
  e[v].push_back(u);
}
void dfs(int u, int f, int dep, int id) {
  fuck(d[id][u] == dep);
  for (auto v : e[u])
    if (v != f) dfs(v, u, dep + 1, id);
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) rtp[i] = -1;
  for (int i = 0; i < n; i++) f[i] = i;
  for (int i = 0; i < k; i++) {
    vector<int> r;
    for (int j = 0; j < n; j++) {
      scanf("%d", &d[i][j]);
      if (d[i][j] == 0) r.push_back(j);
    }
    fuck(((int)(r).size()) == 1);
    rt[i] = r[0];
    if (rtp[rt[i]] == -1)
      rtp[rt[i]] = i, prt.push_back(rt[i]);
    else {
      for (int j = 0; j < n; j++) fuck(d[i][j] == d[rtp[rt[i]]][j]);
    }
  }
  int u = prt[0];
  ins.insert(u);
  for (auto v : prt) {
    if (v == u) continue;
    int idu = rtp[u], idv = rtp[v];
    fuck(d[idu][v] == d[idv][u]);
    int dis = d[idu][v];
    for (int i = 0; i < dis + 1; i++) vec[i].clear();
    for (int i = 0; i < n; i++)
      if (d[idu][i] + d[idv][i] == dis) {
        vec[d[idu][i]].push_back(i);
      }
    for (int i = 0; i < dis + 1; i++) fuck(((int)(vec[i]).size()) == 1);
    for (int i = 1; i < dis + 1; i++) {
      int p = vec[i - 1][0], q = vec[i][0];
      add(p, q);
      ins.insert(p);
      ins.insert(q);
    }
  }
  for (auto p : ins) {
    vector<int> it;
    for (int j = 0; j < k; j++) it.push_back(d[j][p]);
    hs[it] = p;
  }
  for (int i = 0; i < n; i++) ord[i] = i;
  sort(ord, ord + n, [&](int u, int v) { return d[0][u] < d[0][v]; });
  for (int i = 0; i < n; i++) {
    int p = ord[i];
    if (ins.count(p)) continue;
    vector<int> it, nit;
    for (int j = 0; j < k; j++) {
      fuck(d[j][p] > 0);
      it.push_back(d[j][p] - 1);
      nit.push_back(d[j][p]);
    }
    fuck(hs.count(it));
    add(hs[it], p);
    hs[nit] = p;
  }
  for (int i = 0; i < k; i++) dfs(rt[i], -1, 0, i);
  for (auto p : E) printf("%d %d\n", p.first, p.second);
}