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 MAX_K = 201, MAX_N = 30001;
int n, k, root, d[MAX_K][MAX_N], id[MAX_K], belong[MAX_N], father[MAX_N],
    depth[MAX_N], node_of_growth[MAX_N], dis[MAX_N];
vector<int> node_list[MAX_N];
vector<int> edge[MAX_N];
void noSolution() {
  printf("-1\n");
  exit(0);
}
void init() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%d", &d[i][j]);
      if (!d[i][j]) {
        if (id[i])
          noSolution();
        else
          id[i] = j;
      }
    }
    if (!id[i]) noSolution();
  }
  root = id[1];
  for (int i = 1; i <= n; i++) {
    depth[i] = d[1][i];
    belong[i] = root;
  }
}
void solve() {
  for (int i = 2; i <= k; i++) {
    int dis_to_root = d[i][root];
    static int node_on_depth[MAX_N];
    for (int j = 0; j <= dis_to_root; j++) node_on_depth[j] = 0;
    for (int j = 1; j <= n; j++)
      if (d[1][j] + d[i][j] == dis_to_root) node_on_depth[d[1][j]] = j;
    for (int j = 1; j <= dis_to_root; j++)
      father[node_on_depth[j]] = node_on_depth[j - 1];
    for (int j = 1; j <= n; j++) {
      if (!father[j]) {
        int belong_depth = (d[1][j] - d[i][j] + dis_to_root) / 2;
        if (belong_depth > depth[belong[j]])
          belong[j] = node_on_depth[belong_depth];
      }
    }
  }
  for (int i = 1; i <= n; i++) node_list[depth[i]].push_back(i);
  node_of_growth[0] = -1;
  for (int i = 1; i <= n; i++) node_of_growth[i] = i;
  for (int i = 1; i <= n; i++)
    if (father[i]) belong[i] = 0;
  belong[root] = 0;
  for (int i = 1; i < n; i++) {
    for (vector<int>::iterator j = node_list[i].begin(); j < node_list[i].end();
         j++)
      if (!father[*j]) father[*j] = node_of_growth[belong[*j]];
    for (vector<int>::iterator j = node_list[i].begin(); j < node_list[i].end();
         j++)
      if (father[*j] == node_of_growth[belong[*j]])
        node_of_growth[belong[*j]] = *j;
  }
}
void dfs(int loc, int current_dis) {
  dis[loc] = current_dis;
  for (vector<int>::iterator i = edge[loc].begin(); i < edge[loc].end(); i++) {
    if (dis[*i] == -1) dfs(*i, current_dis + 1);
  }
}
void check() {
  for (int i = 1; i <= n; i++)
    if (father[i]) {
      edge[father[i]].push_back(i);
      edge[i].push_back(father[i]);
    }
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= n; j++) dis[j] = -1;
    dfs(id[i], 0);
    for (int j = 1; j <= n; j++)
      if (dis[j] != d[i][j]) noSolution();
  }
}
void display() {
  for (int i = 1; i <= n; i++)
    if (father[i]) printf("%d %d\n", i, father[i]);
}
int main() {
  init();
  solve();
  check();
  display();
}