#include <bits/stdc++.h>
using namespace std;
long long n, m, k;
long long read() {
  long long s = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s * f;
}
const long long maxn = 3e5 + 10;
long long a[maxn];
long long pre[maxn];
long long f[maxn];
long long x[maxn], y[maxn];
long long in(long long l, long long r, long long x) { return x >= l && x <= r; }
void clr(long long l, long long r) {
  for (long long i = l, iend = r; i <= iend; ++i) pre[i] = 0;
}
signed main() {
  n = read(), k = read();
  long long siz = n * k;
  for (long long i = 1, iend = siz; i <= iend; ++i) a[i] = read();
  long long u = k - 1;
  long long l = 1, r = u;
  while (l <= n) {
    if (r > n) r = n;
    for (long long i = 1, iend = siz; i <= iend; ++i) {
      long long v = a[i];
      if (!in(l, r, v)) continue;
      if (f[v]) continue;
      if (!pre[v]) {
        pre[v] = i;
        continue;
      }
      x[v] = pre[v];
      y[v] = i;
      f[v] = 1;
      clr(l, r);
    }
    l += u;
    r += u;
  }
  for (long long i = 1, iend = n; i <= iend; ++i) {
    cout << x[i] << " " << y[i] << '\n';
  }
}
