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 = 3e4 + 5, K = 200 + 5;
vector<int> lvl[K][N], adj[N];
int n, k, id[K], dist[K][N];
int prv[K], h[N];
void terminate(bool b) {
  if (b) {
    cout << -1;
    exit(0);
  }
}
void add_edge(int u, int v) {
  adj[u].push_back(v);
  adj[v].push_back(u);
}
void dfs(int u, int par) {
  for (auto v : adj[u])
    if (v ^ par) {
      h[v] = h[u] + 1;
      dfs(v, u);
    }
}
void base_conditions() {
  for (int i = 0; i < k; i++) {
    terminate(lvl[i][0].size() ^ 1), id[i] = lvl[i][0][0];
    for (int j = 0; j < i; j++) terminate(dist[i][id[j]] ^ dist[j][id[i]]);
  }
}
void build_graph() {
  fill(prv, prv + k, id[0]);
  for (int h = 1; !lvl[0][h].empty(); h++)
    for (auto u : lvl[0][h]) {
      bool done = false;
      for (int i = 0; i < k; i++)
        if (dist[0][id[i]] == dist[0][u] + dist[i][u]) {
          if (!done) {
            add_edge(u, prv[i]);
            done = true;
          }
          prv[i] = u;
        }
      if (!done)
        for (auto v : lvl[0][h - 1]) {
          bool flag = true;
          for (int i = 0; flag && i < k; i++)
            flag &= dist[i][v] + 1 == dist[i][u];
          if (flag) {
            add_edge(u, v);
            break;
          }
          terminate(v == lvl[0][h - 1].back());
        }
    }
}
void check_graph() {
  for (int i = 0; i < k; i++) {
    memset(h, 0, sizeof h), dfs(id[i], -1);
    for (int u = 0; u < n; u++) terminate(dist[i][u] ^ h[u]);
  }
}
void read_input() {
  cin >> n >> k;
  for (int i = 0; i < k; i++)
    for (int u = 0; u < n; u++) {
      cin >> dist[i][u];
      lvl[i][dist[i][u]].push_back(u);
    }
}
void solve() {
  base_conditions();
  build_graph();
  check_graph();
}
void write_output() {
  for (int u = 0; u < n; u++)
    for (auto v : adj[u])
      if (u < v) cout << u + 1 << ' ' << v + 1 << endl;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  read_input(), solve(), write_output();
  return 0;
}