func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     int n, k;     cin >> n >> k;     vector<int> *dist = new vector<int>[n];     int len = 0;     for (int i = 0; i < n; i++) {       int d;       cin >> d;       dist[d].push_back(i);       len = max(len, d);     }     if (dist[0].size() != 1) {       cout << -1;       return 0;     }     for (int i = 1; i <= len; i++) {       if (dist[i].empty() ||           dist[i].size() > (long long)dist[i - 1].size() * (k - (i != 1))) {         cout << -1;         return 0;       }     }     cout << n - 1 << endl;     for (int i = 1; i <= len; i++) {       int counter = 0;       int index = 0;       for (int child : dist[i]) {         if (counter == k - (i != 1)) {           counter = 0;           index++;         }         cout << dist[i - 1][index] + 1 <<     << child + 1 << endl;         counter++;       }     }     return 0;   }   