func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m;   int cnt;   int dfn[300005], low[300005], bel[300005], tot, scc;   bool vis[300005], ins[300005];   string ori[100005];   stack<int> s;   map<string, int> hashh;   vector<int> g[300005], dag[300005];   pair<long long, long long> a[300005];   pair<long long, long long> dp[300005];   pair<long long, long long> operator+(const pair<long long, long long> &a,                                        const pair<long long, long long> &b) {     return make_pair(a.first + b.first, a.second + b.second);   }   void down(string &a) {     for (int i = 0; i < a.length(); i++)       if ( A  <= a[i] && a[i] <=  Z ) a[i] = a[i] -  A  +  a ;   }   pair<long long, long long> calc(string a) {     pair<long long, long long> t = make_pair(0, 0);     for (int i = 0; i < a.length(); i++)       if (a[i] ==  r ) t.first++;     t.second = a.length();     return t;   }   void add(string &s) {     down(s);     if (hashh.count(s) == 0) hashh[s] = ++cnt;     pair<long long, long long> t = calc(s);     a[hashh[s]] = t;   }   void tarjan(int u) {     s.push(u);     ins[u] = 1;     dfn[u] = low[u] = ++tot;     for (int i = 0; i < g[u].size(); i++) {       int v = g[u][i];       if (dfn[v] == 0) {         tarjan(v);         low[u] = min(low[u], low[v]);       } else if (ins[v])         low[u] = min(low[u], dfn[v]);     }     if (dfn[u] == low[u]) {       int v;       scc++;       dp[scc] = make_pair(1 << 30, 1 << 30);       do {         v = s.top();         s.pop();         ins[v] = 0;         bel[v] = scc;         dp[scc] = min(dp[scc], a[v]);       } while (v != u);     }   }   void dfs(int u) {     if (vis[u]) return;     vis[u] = 1;     for (int i = 0; i < dag[u].size(); i++) {       int v = dag[u][i];       dfs(v);       dp[u] = min(dp[u], dp[v]);     }   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> ori[i];       add(ori[i]);     }     cin >> m;     for (int i = 1; i <= m; i++) {       string u, v;       cin >> u >> v;       add(u);       add(v);       g[hashh[u]].push_back(hashh[v]);     }     for (int i = 1; i <= cnt; i++)       if (dfn[i] == 0) tarjan(i);     for (int i = 1; i <= cnt; i++)       for (int j = 0; j < g[i].size(); j++)         if (bel[i] != bel[g[i][j]]) dag[bel[i]].push_back(bel[g[i][j]]);     for (int i = 1; i <= scc; i++)       if (vis[i] == 0) dfs(i);     pair<long long, long long> ans;     for (int i = 1; i <= n; i++) ans = ans + dp[bel[hashh[ori[i]]]];     cout << ans.first <<     << ans.second;     return 0;   }   