func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long MOD = (1ll << 32);   const int LOGN = 14;   const long long INF = (1ll << 62);   long long __gcd(long long a, long long b) {     if (b == 0) return a;     return __gcd(b, a % b);   }   bool comp(pair<int, unordered_set<int> >& a,             pair<int, unordered_set<int> >& b) {     return a.second.size() > b.second.size();   }   int main() {     std ::ios_base ::sync_with_stdio(false);     cin.tie(NULL), cout.tie(NULL);     int n, m;     cin >> n >> m;     vector<pair<int, unordered_set<int> > > a(n);     int sz;     int ct = 0;     int ct_p1 = 0;     for (int i = 0; i < n; ++i) {       cin >> sz;       ct += sz;       a[i].first = i;       int x;       for (int j = 0; j < sz; ++j) {         cin >> x;         a[i].second.insert(x);       }     }     ct_p1 = ct % n;     ct /= n;     sort(a.begin(), a.end(), comp);     int l = 0;     int r = n - 1;     vector<vector<int> > ans;     while (l < r) {       int req_l_size = ct;       int req_r_size = ct;       if (l < ct_p1) req_l_size++;       if (r < ct_p1) req_r_size++;       vector<int> temp;       for (auto it : a[l].second) {         if ((int)a[l].second.size() - (int)temp.size() == req_l_size) break;         if (a[r].second.size() == req_r_size) break;         if (a[r].second.find(it) == a[r].second.end()) {           temp.push_back(it);           a[r].second.insert(it);           vector<int> x;           x.push_back(a[l].first);           x.push_back(a[r].first);           x.push_back(it);           ans.push_back(x);         }       }       for (int i = 0; i < temp.size(); ++i) a[l].second.erase(temp[i]);       if (a[r].second.size() == req_r_size) r--;       if (a[l].second.size() == req_l_size) l++;     }     cout << ans.size() << endl;     for (int i = 0; i < ans.size(); ++i)       cout << ans[i][0] + 1 <<     << ans[i][1] + 1 <<     << ans[i][2] << endl;     return 0;   }   