func_code_string: #include <bits/stdc++.h>   using namespace std;   const int mn = 200005;   const int mod = 1e9 + 7;   int n, m;   unordered_set<int> h[mn];   priority_queue<pair<int, int> > q;   int sum = 0;   int maxi, mini;   vector<tuple<int, int, int> > ans;   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) {       int u;       scanf( %d , &u);       for (int j = 1; j <= u; j++) {         int v;         scanf( %d , &v);         h[i].insert(v);       }       sum += u;     }     mini = sum / n;     maxi = mini + (sum % n != 0);     for (int i = 1; i <= n; i++) {       if ((int)h[i].size() >= maxi) {         q.push({(int)h[i].size(), i});       }     }     for (int i = 1; i <= n; i++) {       while ((int)h[i].size() < mini) {         pair<int, int> u = q.top();         q.pop();         for (auto it = h[u.second].begin(); it != h[u.second].end(); it++) {           if (!h[i].count(*it)) {             h[i].insert(*it);             ans.push_back({u.second, i, *it});             h[u.second].erase(it++);             if ((int)h[i].size() == mini || (int)h[u.second].size() <= maxi)               break;           }         }         if ((int)h[u.second].size() >= maxi)           q.push({(int)h[u.second].size(), u.second});       }     }     for (int i = 1; i <= n; i++) {       if (q.top().first == maxi) break;       while ((int)h[i].size() == mini) {         pair<int, int> u = q.top();         q.pop();         for (auto it = h[u.second].begin(); it != h[u.second].end(); it++) {           if (!h[i].count(*it)) {             h[i].insert(*it);             ans.push_back({u.second, i, *it});             h[u.second].erase(it++);             break;           }         }         if ((int)h[u.second].size() >= maxi)           q.push({(int)h[u.second].size(), u.second});       }     }     printf( %d n , (int)ans.size());     for (auto &i : ans) {       printf( %d %d %d n , get<0>(i), get<1>(i), get<2>(i));     }     return 0;   }   