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;
void report() {
  puts("-1");
  exit(0);
}
int n, k, dis[210][30010], b[30010];
unordered_map<int, int> F;
int M[210];
bool vis[30010];
int comp(int a, int b) { return dis[1][a] < dis[1][b]; }
unordered_set<int> st[300010];
set<pair<pair<int, int>, int> > mp;
class hash_table {
 public:
  vector<pair<pair<int, int>, int> > dat[131072];
  void insert(int h1, int h2, int v) {
    int key = (h1 ^ h2) & 131071;
    dat[key].push_back(make_pair(make_pair(h1, h2), v));
  }
  int find(int h1, int h2) {
    int key = (h1 ^ h2) & 131071;
    for (pair<pair<int, int>, int> x : dat[key]) {
      if (x.first.first == h1 && x.first.second == h2) return x.second;
    }
    return 0;
  }
} hs;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%d", &dis[i][j]);
      if (!dis[i][j]) {
        if (M[i]) report();
        M[i] = j;
      }
    }
    if (!M[i]) report();
    F[M[i]] = i;
  }
  sort(M + 2, M + k + 1, comp);
  for (int i = 1; i <= n; i++) b[i] = i;
  sort(b + 1, b + n + 1, comp);
  vis[M[1]] = 1;
  for (int i = 2; i <= k; i++) {
    int now = M[1], D = dis[1][M[i]];
    int x = F[M[i]];
    for (int j = 2; j <= n && now != M[i]; j++) {
      if (dis[x][b[j]] + dis[1][b[j]] == D) {
        if (st[now].find(b[j]) == st[now].end()) {
          st[now].insert(b[j]);
          vis[b[j]] = 1;
        }
        now = b[j];
      }
    }
    if (now != M[i]) report();
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i]) {
      int h1 = 0, h2 = 0;
      for (int j = 1; j <= k; j++) {
        h1 = (1ll * h1 * 117 + dis[j][i]) % 998244353;
        h2 = (1ll * h2 * 137 + dis[j][i]) % 1000000007;
      }
      hs.insert(h1, h2, i);
    }
  }
  for (int T = 1; T <= n; T++) {
    int i = b[T];
    if (!vis[i]) {
      int h1 = 0, h2 = 0;
      for (int j = 1; j <= k; j++) {
        h1 = (1ll * h1 * 117 + (dis[j][i] - 1)) % 998244353;
        h2 = (1ll * h2 * 137 + (dis[j][i] - 1)) % 1000000007;
      }
      int x = hs.find(h1, h2);
      if (!x) report();
      st[x].insert(i);
      h1 = 0, h2 = 0;
      for (int j = 1; j <= k; j++) {
        h1 = (1ll * h1 * 117 + dis[j][i]) % 998244353;
        h2 = (1ll * h2 * 137 + dis[j][i]) % 1000000007;
      }
      hs.insert(h1, h2, i);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j : st[i]) printf("%d %d\n", i, j);
  }
  return 0;
}