#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int a[100005];
vector<int> c[105];
int ans[105][2];
int idx[105], vidx[105], vis[105];
void go(int gn, int kk) {
  if (gn == 0 || kk < 2) {
    return;
  }
  for (int i = (1); i <= (gn); ++i) {
    vis[i] = 0;
  }
  while (1) {
    int mn = 1e9, minidx;
    for (int i = (1); i <= (gn); ++i) {
      if (c[idx[i]][vidx[i]] < mn) {
        mn = c[idx[i]][vidx[i]];
        minidx = i;
      }
    }
    if (vis[minidx] != 0) {
      ans[idx[minidx]][0] = vis[minidx];
      ans[idx[minidx]][1] = mn;
      idx[minidx] = idx[gn];
      vidx[minidx] = vidx[gn];
      gn--;
      go(gn, kk - 1);
      return;
    } else {
      vis[minidx] = mn;
      vidx[minidx]++;
    }
  }
}
void solve() {
  int n, k;
  cin >> n >> k;
  for (int i = (1); i <= (n); ++i) {
    c[i].clear();
  }
  for (int i = (1); i <= (n * k); ++i) {
    cin >> a[i];
    c[a[i]].push_back(i);
  }
  int lay = n / (k - 1) + ((n % (k - 1)) == 0 ? 0 : 1);
  for (int i = (1); i <= (lay); ++i) {
    int l = 0;
    for (int j = (1); j <= (k - 1); ++j) {
      if ((i - 1) * (k - 1) + j > n) {
        break;
      }
      l++;
      idx[j] = (i - 1) * (k - 1) + j;
      vidx[j] = 0;
    }
    go(l, k);
  }
  for (int i = (1); i <= (n); ++i) {
    cout << ans[i][0] << " " << ans[i][1] << "\n";
  }
  cout << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  solve();
  return 0;
}
