#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int maxn = 1005;
void go() {
  int n, k;
  cin >> n >> k;
  vector<int> v[n + 1];
  for (int i = 1; i < n * k + 1; i++) {
    int a;
    cin >> a;
    v[a].push_back(i);
  }
  int fin[101] = {}, l[101], r[101];
  int iter = 0;
  while (1) {
    priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> pq;
    for (int i = 1; i < n + 1; i++) {
      if (!fin[i]) {
        vector<int> a{v[i][1], v[i][0], i, 1};
        pq.push(a);
      }
    }
    if (!pq.size()) break;
    int ok = 0;
    while (pq.size()) {
      auto now = pq.top();
      pq.pop();
      if (now[1] > ok) {
        fin[now[2]] = 1;
        l[now[2]] = now[1];
        r[now[2]] = now[0];
        ok = r[now[2]];
      } else {
        if (now[3] < k - 1) {
          now[3]++;
          now[0] = v[now[2]][now[3]];
          now[1] = v[now[2]][now[3] - 1];
          pq.push(now);
        }
      }
    }
  }
  for (int i = 1; i < n + 1; i++) {
    cout << l[i] << ' ' << r[i] << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int c = 0;
  int t;
  if (!c) {
    t = 1;
  } else {
    cin >> t;
  }
  while (t--) {
    go();
  }
}
