func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 100000 + 7;   vector<vector<int> > g, gr;   vector<char> used;   vector<int> order, component;   void dfs1(int v) {     used[v] = true;     for (size_t i = 0; i < g[v].size(); ++i)       if (!used[g[v][i]]) dfs1(g[v][i]);     order.push_back(v);   }   void dfs2(int v) {     used[v] = true;     component.push_back(v);     for (size_t i = 0; i < gr[v].size(); ++i)       if (!used[gr[v][i]]) dfs2(gr[v][i]);   }   int main() {     int n, cost[MAXN];     cin >> n;     for (int i = 0; i < n; ++i) cin >> cost[i];     int m;     cin >> m;     g.resize(n);     gr.resize(n);     for (int i = 0; i < m; ++i) {       int a, b;       cin >> a >> b;       --a;       --b;       g[a].push_back(b);       gr[b].push_back(a);     }     used.assign(n, false);     for (int i = 0; i < n; ++i)       if (!used[i]) dfs1(i);     used.assign(n, false);     long long ficost = 0;     long long fix = 1;     for (int i = 0; i < n; ++i) {       int v = order[n - 1 - i];       if (!used[v]) {         dfs2(v);         int curmin = INT_MAX;         for (size_t j = 0; j < component.size(); ++j)           curmin = min(curmin, cost[component[j]]);         ficost += curmin;         int curc = 0;         for (size_t j = 0; j < component.size(); ++j)           if (cost[component[j]] == curmin) ++curc;         fix *= curc;         fix %= 1000000000 + 7;         component.clear();       }     }     cout << ficost <<     << fix << endl;   }   