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>
const int N = 30300;
const int Q = 220;
using namespace std;
int n, k;
int p[N];
int bitch[N];
int batya[N];
vector<int> d[Q];
vector<vector<int> > lev;
void wa() {
  cout << -1 << "\n";
  exit(0);
}
void make(int x, int y, int i, int j) {
  if (d[i][y] != d[j][x]) wa();
  for (int z = 0; z <= n; z++) bitch[z] = -1;
  for (int z = 1; z <= n; z++) {
    if (d[i][z] + d[j][z] == d[i][y]) {
      if (bitch[d[i][z]] != -1) wa();
      bitch[d[i][z]] = z;
    }
  }
  int last = 0;
  for (int i = 1; i <= n; i++)
    if (bitch[i] != -1) last = i;
  for (int h = 1; h <= last; h++) {
    int x = bitch[h - 1], y = bitch[h];
    if (x == -1) wa();
    p[y] = x;
  }
}
int inv[Q][N];
long long A[Q][N];
map<long long, int> D;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long get(int x, int dif) {
  long long res = 0;
  for (int i = 1; i <= k; i++) {
    if (inv[i][x] + dif < 0) return (long long)rng();
    res ^= A[i][inv[i][x] + dif];
  }
  return res;
}
void build(vector<int> v) {
  D.clear();
  for (int x : v) {
    D[get(x, 0)] = x;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  lev.resize(n);
  for (int i = 1; i <= k; i++) {
    d[i].resize(n + 1);
    for (int j = 1, x; j <= n; j++) {
      cin >> x;
      d[i][j] = x;
      if (i == 1) lev[x].push_back(j);
      inv[i][j] = x;
      A[i][j - 1] = (long long)rng();
      if (!x) {
        if (batya[i]) wa();
        batya[i] = j;
      }
    }
    if (!batya[i]) wa();
  }
  int root = lev[0][0];
  for (int i = 2; i <= k; i++) {
    int x = batya[i];
    make(root, x, 1, i);
  }
  for (int i = 1; i < n; i++) {
    if (lev[i].empty()) break;
    build(lev[i - 1]);
    for (int x : lev[i]) {
      if (p[x]) continue;
      long long hsh = get(x, -1);
      if (D.find(hsh) == D.end()) {
        wa();
      }
      p[x] = D[hsh];
    }
  }
  for (int i = 1; i <= n; i++) {
    if (i != root && !p[i]) wa();
  }
  for (int i = 1; i <= n; i++)
    if (root != i) cout << i << " " << p[i] << "\n";
}