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;
unsigned long long read() {
  unsigned long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
map<unsigned long long, unsigned long long> Mp;
bitset<30005> G[30005];
unsigned long long n, k, Now[30005], p[30005], A[30005], B[30005], cnt,
    vis[30005];
pair<unsigned long long, unsigned long long> a[30005];
vector<unsigned long long> E[30005];
void add(unsigned long long x, unsigned long long y) {
  if (G[x][y]) return;
  G[x][y] = G[y][x] = 1;
  A[++cnt] = x;
  B[cnt] = y;
  vis[x] = vis[y] = 1;
}
signed main() {
  n = read();
  k = read();
  for (unsigned long long i = 1; i <= k; i++) {
    unsigned long long now = 0;
    for (unsigned long long j = 1; j <= n; j++) Now[j] = read();
    for (unsigned long long j = 1; j <= n; j++)
      if (!Now[j]) {
        now = j;
        break;
      }
    if (!now) return puts("-1"), 0;
    for (unsigned long long j = now + 1; j <= n; j++)
      if (!Now[j]) return puts("-1"), 0;
    p[i] = now;
    E[now].push_back(0);
    for (unsigned long long j = 1; j <= n; j++) E[now].push_back(Now[j]);
  }
  for (unsigned long long i = 1; i <= n; i++) a[i] = make_pair(E[p[1]][i], i);
  vis[p[1]] = 1;
  sort(a + 1, a + 1 + n);
  for (unsigned long long i = 2; i <= k; i++) {
    unsigned long long now = p[1];
    for (unsigned long long j = 2; j <= n; j++) {
      unsigned long long x = a[j].second;
      if (a[j].first + E[p[i]][x] == E[p[1]][p[i]]) add(now, x), now = x;
    }
  }
  for (unsigned long long i = 1; i <= n; i++) {
    if (!vis[i]) continue;
    unsigned long long Hash = 0;
    for (unsigned long long j = 1; j <= k; j++)
      Hash = Hash * 44042137 + E[p[j]][i];
    Mp[Hash] = i;
  }
  for (unsigned long long i = 2; i <= n; i++) {
    unsigned long long x = a[i].second;
    if (vis[x]) continue;
    unsigned long long Hash = 0;
    for (unsigned long long j = 1; j <= k; j++) {
      Hash = Hash * 44042137 + E[p[j]][x] - 1ll;
    }
    if (!Mp[Hash]) return puts("-1"), 0;
    add(Mp[Hash], x);
    Hash = 0;
    for (unsigned long long j = 1; j <= k; j++)
      Hash = Hash * 44042137 + E[p[j]][x];
    Mp[Hash] = x;
  }
  for (unsigned long long i = 1; i <= cnt; i++)
    printf("%lld %lld\n", A[i], B[i]);
  return 0;
}