#include <bits/stdc++.h>
using namespace std;
template <typename T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using MaxHeap = priority_queue<T>;
const long double PI = 3.14159265358979323846;
const long double E = 2.718281828459;
long long MOD = (1ll << 31) - 1;
long long M(long long n) { return (n % MOD + MOD) % MOD; }
long long pow2(long long n) { return 1ll << n; }
mt19937 rng(
    (unsigned int)chrono::steady_clock::now().time_since_epoch().count());
int main(int argn, char **argv) {
  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);
  int T = 1;
  for (int(I) = (0); (I) <= ((T)-1); (I)++) {
    long long n, k;
    cin >> n >> k;
    vector<long long> pos[n + 1];
    for (int(p) = (0); (p) <= ((n * k) - 1); (p)++) {
      long long col;
      cin >> col;
      pos[col].emplace_back(p + 1);
    }
    vector<tuple<long long, long long, long long>> seg;
    for (int(col) = (1); (col) <= (n); (col)++) {
      for (int(i) = (0); (i) <= ((k - 1) - 1); (i)++) {
        seg.emplace_back(pos[col][i + 1], pos[col][i], col);
      }
    }
    sort((seg).begin(), (seg).end());
    long long tot = 0;
    vector<long long> done(n + 1, 0);
    vector<pair<long long, long long>> ans(n + 1);
    while (tot < n) {
      long long idx = 0, crt = 0;
      while (idx < seg.size()) {
        auto [r, l, col] = seg[idx++];
        if (l <= crt || done[col]) continue;
        done[col] = 1, tot++;
        ans[col] = {l, r};
        crt = r;
      }
    }
    for (int(col) = (1); (col) <= (n); (col)++) {
      auto [l, r] = ans[col];
      ;
      cout << l << " " << r << endl;
    }
  }
  return 0;
}
