#include <bits/stdc++.h>
using namespace std;
void optIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int aa[120], ab[120], a[10020];
int seg[10020];
void solve() {
  int n, k;
  cin >> n >> k;
  int nn = n * k;
  int lim = ceil((double)n / (k - 1));
  for (int i = 0; i < nn; ++i) cin >> a[i];
  int last[120];
  memset(last, (-1), sizeof(last));
  memset(aa, (-1), sizeof(aa));
  for (int i = 0; i < nn; ++i) {
    if (last[a[i]] == -1) {
      last[a[i]] = i;
      continue;
    }
    if (aa[a[i]] != -1) continue;
    bool ok = 1;
    for (int j = last[a[i]]; j < i + 1; ++j) {
      if (seg[j] + 1 > lim) {
        ok = 0;
        break;
      }
    }
    if (!ok) {
      last[a[i]] = i;
      continue;
    }
    for (int j = last[a[i]]; j < i + 1; ++j) seg[j]++;
    aa[a[i]] = last[a[i]] + 1;
    ab[a[i]] = i + 1;
  }
  for (int i = 1; i < n + 1; ++i) {
    assert(aa[i] != -1);
    cout << aa[i] << " " << ab[i] << "\n";
  }
}
int main() {
  optIO();
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
