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 = 64000;
int par[N], n, dis[N], disp[N], dit[N];
vector<int> tr[N];
vector<pair<int, int> > subtr[N];
bool ok[N];
void endd() {
  puts("-1");
  exit(0);
}
void pathfind(int v) {
  int p = par[v];
  int ps[N] = {};
  fill(ps, ps + 2 * n, -1);
  ps[disp[v] + n] = v;
  ps[-disp[v] + n] = p;
  for (int i = 0; i < n; i++)
    if (par[i] == p) {
      int d = disp[i] - dis[i] + n;
      if (ps[d] == -1 || dis[i] < dis[ps[d]]) ps[d] = i;
    }
  for (int i = 0; i < n; i++)
    if (par[i] == p) {
      int d = disp[i] - dis[i] + n;
      if (ps[d] != -1 && dis[i] == dis[ps[d]] && i != ps[d]) endd();
    }
  for (int i = 2; i < 2 * n; i++)
    if (ps[i] != -1 && ps[i - 2] != -1) {
      int a = ps[i], b = ps[i - 2];
      tr[a].push_back(b);
      tr[b].push_back(a);
      ok[a] = true;
    }
  for (int i = 0; i < n; i++)
    if (par[i] == p) {
      int d = disp[i] - dis[i] + n;
      par[i] = ps[d];
      int dtopar = dis[i] - dis[par[i]];
      if (i != par[i] && par[i] != p)
        subtr[ps[d]].push_back(make_pair(i, dtopar));
    }
  vector<pair<int, int> > vt;
  for (int i = 0; i < subtr[p].size(); i++) {
    auto u = subtr[p][i];
    if (par[u.first] == p) vt.push_back(u);
  }
  subtr[p] = vt;
}
void dfs(int x, int p, int* a) {
  a[x] = 0;
  if (p != -1) a[x] = a[p] + 1;
  for (auto u : subtr[x]) a[u.first] = a[x] + u.second;
  for (auto u : tr[x])
    if (u != p) dfs(u, x, a);
}
void find(int v, int* a) {
  memset(a, 0, sizeof a);
  dfs(v, -1, a);
}
int main() {
  int k;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    int v = -1;
    bool has[N] = {};
    for (int j = 0; j < n; j++) {
      scanf("%d", &dis[j]);
      has[dis[j]] = true;
      if (dis[j] == 0) {
        if (v != -1) endd();
        v = j;
      }
    }
    if (v == -1) endd();
    int mx = *max_element(dis, dis + n);
    for (int i = 0; i < mx; i++)
      if (!has[i]) endd();
    if (!i) {
      ok[v] = true;
      for (int j = 0; j < n; j++) {
        par[j] = v;
        if (j != v) subtr[v].push_back(make_pair(j, dis[j]));
      }
      continue;
    }
    int p = par[v];
    find(par[v], disp);
    if (!ok[v]) pathfind(v);
    find(p, dit);
    for (int i = 0; i < n; i++)
      if (disp[i] != dit[i]) endd();
    find(v, disp);
    for (int i = 0; i < n; i++)
      if (disp[i] != dis[i]) endd();
    ok[v] = true;
  }
  for (int i = 0; i < n; i++) {
    int pre[N] = {i};
    for (auto u : tr[i])
      if (u > i) cout << u + 1 << ' ' << i + 1 << endl;
    for (auto u : subtr[i]) pre[u.second] = u.first;
    for (auto u : subtr[i])
      cout << u.first + 1 << ' ' << pre[u.second - 1] + 1 << endl;
  }
  return 0;
}