func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long int MOD = 1e9 + 7;   const long long int MAXN = 100010;   long long int par[MAXN], nxt[MAXN];   int find_root(int a) {     if (par[a] == a) {       return a;     }     int f = par[a];     par[a] = find_root(par[a]);     nxt[a] = (nxt[a] + nxt[f]) % MOD;     if (nxt[a] < 0) nxt[a] += MOD;     return par[a];   }   int main() {     long long int n;     cin >> n;     for (int i = 1; i <= n; i++) {       par[i] = i;     }     long long int answer = 0;     for (int i = 1; i <= n; i++) {       long long int k;       cin >> k;       for (int j = 0; j < k; j++) {         long long int v, x;         cin >> v >> x;         long long int root = find_root(v);         par[root] = i;         answer = (answer + ((nxt[v] + x) % MOD)) % MOD;         while (answer < 0) answer += MOD;         if (x < 0) x += MOD;         nxt[root] = ((nxt[v] + x) % MOD);         if (nxt[root] < 0) {           nxt[root] += MOD;         }       }     }     cout << answer % MOD << endl;   }   