#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    int n, k, sum, m;
    cin >> n >> k;
    sum = n * k;
    m = ceil(1.0 * n / (k - 1));
    vector<int> A(sum), B(n + 1, 0);
    for (int i = 0; i < sum; i++) {
      cin >> A[i];
    }
    vector<vector<int>> ans(n + 1, vector<int>(2, -1));
    unordered_map<int, int> C;
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < sum; j++) {
        if (B[A[j]] == 0) {
          if (C.count(A[j])) {
            ans[A[j]][0] = C[A[j]] + 1;
            ans[A[j]][1] = j + 1;
            B[A[j]] = 1;
            C.clear();
          } else {
            C[A[j]] = j;
          }
        }
      }
      C.clear();
    }
    for (int i = 1; i <= n; i++) {
      cout << ans[i][0] << " " << ans[i][1] << "\n";
    }
  }
  return 0;
}
