#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n * k + 1);
  for (long long i = 1; i <= n * k; i++) {
    cin >> a[i];
  }
  long long lim = (n + k - 2) / (k - 1);
  long long cnt = 0, iter = 0;
  vector<pair<long long, long long>> answer(n + 1);
  vector<bool> killed(n + 1);
  while (cnt < n) {
    iter++;
    assert(iter <= lim);
    vector<long long> st;
    vector<bool> used(n + 1);
    for (long long i = 1; i <= n * k; i++) {
      if (killed[a[i]]) {
        continue;
      }
      if (!used[a[i]]) {
        st.push_back(i);
        used[a[i]] = true;
      } else {
        while (a[st.back()] != a[i]) {
          used[a[st.back()]] = false;
          st.pop_back();
        }
        answer[a[i]] = {st.back(), i};
        killed[a[i]] = true;
        cnt++;
        for (auto it : st) {
          used[a[it]] = false;
        }
        st = {};
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    cout << answer[i].first << ' ' << answer[i].second << '\n';
  }
}
