#include <bits/stdc++.h>
using namespace std;
int c[10005];
int lst[10005], nxt[10005];
int a[10005], b[10005];
int vitore[10005];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n * k; i++) scanf("%d", c + i);
  for (int i = n * k; i; i--) {
    nxt[i] = lst[c[i]];
    lst[c[i]] = i;
  }
  int mx = (n + k - 2) / (k - 1);
  set<int> se;
  for (int i = 1; i <= n * k; i++) {
    if (vitore[c[i]] >= 1) {
      a[c[i]] = vitore[c[i]];
      b[c[i]] = i;
      vitore[c[i]] = -1;
      se.erase(i);
    } else if (vitore[c[i]] == 0) {
      se.insert(nxt[i]);
      vitore[c[i]] = i;
      if (se.size() > mx) {
        auto it = se.end();
        --it;
        int ase = c[*it];
        se.erase(it);
        vitore[ase] = 0;
      }
    }
  }
  for (int i = 1; i <= n; i++) printf("%d %d\n", a[i], b[i]);
  return 0;
}
