#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  long long n, k;
  cin >> n >> k;
  long long m = n * k;
  vector<long long> a(m);
  for (long long i = 0; i < m; ++i) {
    cin >> a[i];
    --a[i];
  }
  vector<long long> ans1(n);
  vector<long long> ans2(n);
  vector<long long> used(n);
  long long cnt = 0;
  while (cnt < n) {
    vector<long long> c(n);
    for (long long i = 0; i < m; ++i) {
      if (used[a[i]]) {
        continue;
      }
      if (c[a[i]]) {
        ans1[a[i]] = c[a[i]];
        ans2[a[i]] = i + 1;
        used[a[i]] = true;
        ++cnt;
        if (cnt == n) {
          break;
        }
        for (long long j = 0; j < n; ++j) {
          c[j] = 0;
        }
      }
      c[a[i]] = i + 1;
    }
  }
  for (long long i = 0; i < n; ++i) {
    cout << ans1[i] << " " << ans2[i] << endl;
  }
  return 0;
}
