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;
vector<vector<int> > adj(30001), d(30001), nodes(30001), depthNodes(30001),
    parent(30001);
int n, root, t[30001];
bool valid = 1, visited[30001];
vector<int> v;
void ReadDistance() {
  int k = 0, c = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &t[i]);
    c += (t[i] == 0);
    if (t[i] == 0) k = i;
  }
  valid &= (c == 1);
  if (valid) {
    d[k].resize(n + 1);
    for (int i = 1; i <= n; ++i) d[k][i] = t[i];
    v.push_back(k);
  }
  if (valid && root == 0) {
    root = k;
    parent[root].push_back(root);
    visited[root] = 1;
    for (int i = 1; i <= n; ++i) depthNodes[d[root][i]].push_back(i);
  }
}
void AddEdge(int i, int j) {
  if (d[root][i] > d[root][j]) swap(i, j);
  if (visited[j] == 0) {
    adj[i].push_back(j);
    adj[j].push_back(i);
    visited[j] = 1;
  }
}
void FixSpecialNode(int k) {
  if (k == root) return;
  for (int i = 0; i <= n; ++i) t[i] = 0;
  for (int i = 1; i <= n; ++i) {
    if (d[root][i] + d[k][i] == d[root][k]) t[d[k][i]] = i;
  }
  for (int i = 0; i < d[root][k]; ++i) AddEdge(t[i], t[i + 1]);
  parent[k].resize(d[root][k] + 1);
  for (int i = 0; i <= d[root][k]; ++i) parent[k][i] = t[i];
}
void FixSpecialNodes() {
  if (valid == 0) return;
  for (auto k : v) FixSpecialNode(k);
}
int GetAncestor(int k, int i) {
  int x = d[root][k] + d[k][i] - d[root][i];
  if (x % 2 != 0 || x < 0)
    return 0;
  else
    return parent[k][x / 2];
}
void FixNonSpecialNode(int i) {
  int j = 0;
  for (auto k : v) {
    int x = GetAncestor(k, i);
    if (x == 0) continue;
    if (j == 0 || d[root][x] > d[root][j]) j = x;
  }
  if (j == 0) {
    valid = 0;
    return;
  }
  int x = d[root][i] - d[root][j];
  if (x > nodes[j].size())
    valid = 0;
  else {
    AddEdge(nodes[j][x - 1], i);
    if (x == nodes[j].size()) nodes[j].push_back(i);
  }
}
void FixNonSpecialNodes() {
  if (valid == 0) return;
  for (int i = 1; i <= n; ++i) nodes[i].push_back(i);
  for (auto u : depthNodes) {
    for (auto i : u) {
      if (visited[i] == 0) FixNonSpecialNode(i);
      if (valid == 0) break;
    }
    if (valid == 0) break;
  }
}
void CheckDFS(int i) {
  for (auto k : adj[i]) {
    if (t[k] == n) {
      t[k] = 1 + t[i];
      CheckDFS(k);
    }
  }
}
void CheckSpecialNode(int s) {
  if (valid == 0) return;
  for (int i = 1; i <= n; ++i) t[i] = n;
  t[s] = 0;
  CheckDFS(s);
  for (int i = 1; i <= n && valid == 1; ++i) valid &= (t[i] == d[s][i]);
}
void Check() {
  if (valid == 0) return;
  for (auto k : v) CheckSpecialNode(k);
}
void PrintDFS(int i, int p) {
  for (auto k : adj[i]) {
    if (k != p) {
      printf("%d %d\n", i, k);
      PrintDFS(k, i);
    }
  }
}
int main() {
  int k;
  scanf("%d%d", &n, &k);
  while (k--) ReadDistance();
  FixSpecialNodes();
  FixNonSpecialNodes();
  if (valid)
    PrintDFS(1, 0);
  else
    printf("-1\n");
  return 0;
}