description: The numbers 1,   2,   ...,   n ⋅ k are colored with n colors. These colors are indexed by 1,   2,   ...,   n. For each 1 ≤ i ≤ n, there are exactly k numbers colored with color i.
  
  Let [a,   b] denote the interval of integers between a and b inclusive, that is, the set \\{a,   a + 1,   ...,   b\}. You must choose n intervals [a_1,   b_1],   [a_2,   b_2],   ..., [a_n,   b_n] such that: 
  
    * for each 1 ≤ i ≤ n, it holds 1 ≤ a_i < b_i ≤ n ⋅ k; 
    * for each 1 ≤ i ≤ n, the numbers a_i and b_i are colored with color i; 
    * each number 1 ≤ x ≤ n ⋅ k belongs to at most \left⌈ (n)/(k - 1) \right⌉ intervals. 
  
  
  
  One can show that such a family of intervals always exists under the given constraints.
  
  Input
  
  The first line contains two integers n and k (1 ≤ n ≤ 100, 2 ≤ k ≤ 100) — the number of colors and the number of occurrences of each color.
  
  The second line contains n ⋅ k integers c_1,   c_2,   ...,   c_{nk} (1 ≤ c_j ≤ n), where c_j is the color of number j. It is guaranteed that, for each 1 ≤ i ≤ n, it holds c_j = i for exactly k distinct indices j.
  
  Output
  
  Output n lines. The i-th line should contain the two integers a_i and b_i.
  
  If there are multiple valid choices of the intervals, output any.
  
  Examples
  
  Input
  
  
  4 3
  2 4 3 1 1 4 2 3 2 1 3 4
  
  
  Output
  
  
  4 5
  1 7
  8 11
  6 12
  
  Input
  
  
  1 2
  1 1
  
  
  Output
  
  
  1 2
  
  
  Input
  
  
  3 3
  3 1 2 3 2 1 2 1 3
  
  
  Output
  
  
  6 8
  3 7
  1 4
  
  Input
  
  
  2 3
  2 1 1 1 2 2
  
  
  Output
  
  
  2 3
  5 6
  
  Note
  
  In the first sample, each number can be contained in at most \left⌈ (4)/(3 - 1) \right⌉ = 2 intervals. The output is described by the following picture:
  
  <image>
  
  In the second sample, the only interval to be chosen is forced to be [1,   2], and each number is indeed contained in at most \left⌈ (1)/(2 - 1) \right⌉ = 1 interval.
  
  In the third sample, each number can be contained in at most \left⌈ (3)/(3 - 1) \right⌉ = 2 intervals. The output is described by the following picture:
  
  <image>
solution: #include <bits/stdc++.h>
  using namespace std;
  const long long inf = 1e18;
  template <typename T>
  ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    for (long long i = 0; i < v.size(); ++i) {
      os << v[i];
      if (i != v.size() - 1) os << ", ";
    }
    os << "]";
    return os;
  }
  template <typename T>
  ostream& operator<<(ostream& os, const set<T>& v) {
    os << "{";
    for (auto it : v) {
      os << it;
      if (it != *v.rbegin()) os << ", ";
    }
    os << "}";
    return os;
  }
  template <typename T, typename S>
  ostream& operator<<(ostream& os, const map<T, S>& v) {
    os << "{";
    for (auto it : v) {
      os << it.first << " : " << it.second;
      if (it != *v.rbegin()) os << ", ";
    }
    os << "}";
    return os;
  }
  template <typename T, typename S>
  ostream& operator<<(ostream& os, const pair<T, S>& v) {
    os << "(";
    os << v.first << ", " << v.second << ")";
    return os;
  }
  const long long mod = 1e9 + 7;
  long long fin(long long a, vector<pair<long long, long long>>& par) {
    if (par[a].first == a)
      return a;
    else
      return fin(par[a].first, par);
  }
  bool uni(long long a, long long b, vector<pair<long long, long long>>& par) {
    long long o = fin(a, par);
    long long t = fin(b, par);
    if (o == t) return true;
    if (par[t].second > par[o].second) swap(o, t);
    if (par[t].second == par[o].second) par[o].second++;
    par[t].first = o;
    return false;
  }
  long long power(long long x, long long y, long long m) {
    if (y == 0) return 1;
    long long p = power(x, y / 2, m) % m;
    p = (p * p) % m;
    return (y % 2 == 0) ? p : (x * p) % m;
  }
  long long fin_par(vector<vector<long long>>& bin, long long a, long long p) {
    long long c = a;
    for (long long i = 0; i < 22; i++) {
      if ((1 << i) & p) {
        c = bin[c][i];
      }
    }
    return c;
  }
  long long lca(vector<vector<long long>>& bin, long long a, long long b,
                vector<long long>& d) {
    if (d[a] > d[b]) {
      swap(a, b);
    }
    long long dif = d[b] - d[a];
    long long prod = (1ll << 29);
    for (long long i = 29; i >= 0; i--) {
      if (dif & prod) {
        b = bin[b][i];
      }
      prod /= 2;
    }
    if (b == a) return a;
    prod = (1ll << 29);
    for (long long i = 29; i >= 0; i--) {
      if (bin[b][i] != bin[a][i]) {
        b = bin[b][i];
        a = bin[a][i];
      }
      prod /= 2;
    }
    return bin[a][0];
  }
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  long long a[1000000];
  map<long long, long long> mp;
  set<long long> del;
  vector<pair<long long, pair<long long, long long>>> segs;
  set<long long> st;
  void solve() {
    long long n, k;
    cin >> n >> k;
    for (long long i = 0; i < n * k; i++) {
      cin >> a[i];
    };
    long long maxi = (n + k - 2) / (k - 1);
    st.clear();
    mp.clear();
    del.clear();
    segs.clear();
    st.insert(0);
    long long pt = 0;
    for (long long i = 1; i < n + 1; i++) mp[i] = -1;
    for (long long i = 0; i < n * k; i++) {
      if (!del.count(a[i]) && mp[a[i]] != -1) {
        del.insert(a[i]);
        st.insert(i);
        segs.push_back({a[i], {mp[a[i]], i}});
        mp[a[i]] = -1;
      } else if (!del.count(a[i])) {
        mp[a[i]] = i;
      }
      while (st.size() > maxi) {
        st.erase(st.begin());
        while (pt < *st.begin()) {
          mp[a[pt]] = -1;
          pt++;
        }
      }
      if (segs.size() == n) break;
    }
    sort((segs).begin(), (segs).end());
    for (auto it : segs) {
      cout << it.second.first + 1 << " " << it.second.second + 1 << "\n";
    }
  }
  int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    { solve(); }
  }
  