func_code_string: #include <bits/stdc++.h>   using namespace std;   inline int read() {     int num = 0;     char c = getchar();     if (c ==  - ) return -read();     while (c >=  0  && c <=  9 ) {       num = (num << 3) + (num << 1) + c -  0 ;       c = getchar();     }     return num;   }   inline long long READ() {     long long num = 0;     char c = getchar();     if (c ==  - ) return -READ();     while (c >=  0  && c <=  9 ) {       num = (num << 3) + (num << 1) + c -  0 ;       c = getchar();     }     return num;   }   vector<int> nz[100007], nf[100007];   pair<int, int> en[100007];   int cost[100007];   int djg = 0;   bool lgl[100007], l8[100007];   int minv = ((int)0x3f3f3f3f), mincnt = 0;   long long ans = 1, ans2 = 0;   int n, m;   void dfs(int now) {     l8[now] = 1;     for (int i = 0; i < ((int)(nz[now]).size()); i++)       if (!l8[nz[now][i]]) dfs(nz[now][i]);     en[now] = make_pair(djg++, now);   }   void dfs2(int now) {     lgl[now] = 1;     if (cost[now] < minv) {       minv = cost[now];       mincnt = 1;     } else if (cost[now] == minv)       mincnt++;     for (int i = 0; i < ((int)(nf[now]).size()); i++)       if (!lgl[nf[now][i]]) dfs2(nf[now][i]);   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , cost + i);     scanf( %d , &m);     for (int i = 0; i < m; i++) {       int a, b;       scanf( %d%d , &a, &b);       nz[a].push_back(b);       nf[b].push_back(a);     }     for (int i = 1; i <= n; i++)       if (!l8[i]) dfs(i);     sort(en + 1, en + n + 1);     for (int i = n; i >= 1; i--)       if (!lgl[en[i].second]) {         minv = ((int)0x3f3f3f3f);         dfs2(en[i].second);         ans = ans * mincnt % 1000000007;         ans2 += minv;       }     printf( %I64d %I64d n , ans2, ans);     return 0;   }   