#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int getprev(int i, vector<int> &nxts) {
  auto j = lower_bound(nxts.begin(), nxts.end(), i) - nxts.begin();
  if (j == 0) return -1;
  return nxts[j - 1];
}
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> cols(n * k);
  vector<vector<int>> nxt(n);
  for (int i = 0; i < n * k; ++i) {
    int c;
    cin >> c;
    c--;
    cols[i] = c;
    nxt[c].push_back(i);
  }
  int LIM = (n + k - 2) / (k - 1);
  vector<pair<int, int>> ans(n, {-1, -1});
  vector<int> cnt(n * k);
  for (int i = 0; i < n * k; ++i) {
    if (ans[cols[i]].first != -1) continue;
    int j = getprev(i, nxt[cols[i]]);
    if (j == -1) continue;
    int mx = *max_element(cnt.begin() + j, cnt.begin() + i + 1);
    if (mx == LIM) continue;
    for (int a = j; a < i + 1; ++a) cnt[a]++;
    ans[cols[i]] = {j, i};
  }
  for (int i = 0; i < n; ++i) {
    assert(ans[i].first != -1);
    cout << ans[i].first + 1 << ' ' << ans[i].second + 1 << '\n';
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  while (t--) {
    solve();
    cout << '\n';
  }
}
