#include <bits/stdc++.h>   using namespace std;   const int MAX_SIZE = 10000;   void solve() {     int t;     cin >> t;     string str[2];     map<string, vector<string>> m;     string tmp;     for (int i = 0; i < t; i++) {       cin >> str[0] >> tmp >> str[1];       m[str[0]].push_back(str[1]);     }     int a, b, c;     cin >> a >> b >> c;     int minDiff = -1;     int ii, jj, kk;     vector<vector<int>> idxs;     for (int i = 1; i <= 5; i++) {       for (int j = 1; j <= 5; j++) {         for (int k = 1; k <= 5; k++) {           if (i + j + k == 7) {             int minNum = a / i;             int maxNum = a / i;             maxNum = max(maxNum, b / j);             minNum = min(minNum, b / j);             maxNum = max(maxNum, c / k);             minNum = min(minNum, c / k);             if (minDiff == -1 || minDiff > maxNum - minNum) {               idxs.clear();               minDiff = maxNum - minNum;               ii = i;               jj = j;               kk = k;               vector<int> vec;               vec.push_back(ii);               vec.push_back(jj);               vec.push_back(kk);               idxs.push_back(vec);             } else if (minDiff == maxNum - minNum) {               vector<int> vec;               vec.push_back(i);               vec.push_back(j);               vec.push_back(k);               idxs.push_back(vec);             }           }         }       }     }     vector<string> names2;     names2.push_back( Troll );     names2.push_back( Dracul );     names2.push_back( Anka );     names2.push_back( Snowy );     names2.push_back( Hexadecimal );     names2.push_back( Chapay );     names2.push_back( Cleo );     vector<int> np;     for (int i = 0; i < 7; i++) np.push_back(i);     int maxCnt = -1;     for (int l = 0; l < idxs.size(); l++) {       ii = idxs[l][0];       jj = idxs[l][1];       kk = idxs[l][2];       do {         vector<string> cmpstr;         for (int i = 0; i < ii; i++) cmpstr.push_back(names2[np[i]]);         int icnt = 0;         for (int i = 0; i < cmpstr.size(); i++) {           for (int j = 0; j < cmpstr.size(); j++) {             if (cmpstr[i] == cmpstr[j]) continue;             if (m.count(cmpstr[i])) {               if (m[cmpstr[i]].end() !=                   find(m[cmpstr[i]].begin(), m[cmpstr[i]].end(), cmpstr[j])) {                 icnt++;               }             }           }         }         cmpstr.clear();         for (int i = ii; i < jj + ii; i++) cmpstr.push_back(names2[np[i]]);         int jcnt = 0;         for (int i = 0; i < cmpstr.size(); i++) {           for (int j = 0; j < cmpstr.size(); j++) {             if (cmpstr[i] == cmpstr[j]) continue;             if (m.count(cmpstr[i])) {               if (m[cmpstr[i]].end() !=                   find(m[cmpstr[i]].begin(), m[cmpstr[i]].end(), cmpstr[j])) {                 jcnt++;               }             }           }         }         cmpstr.clear();         for (int i = ii + jj; i < 7; i++) cmpstr.push_back(names2[np[i]]);         int kcnt = 0;         for (int i = 0; i < cmpstr.size(); i++) {           for (int j = 0; j < cmpstr.size(); j++) {             if (cmpstr[i] == cmpstr[j]) continue;             if (m.count(cmpstr[i])) {               if (m[cmpstr[i]].end() !=                   find(m[cmpstr[i]].begin(), m[cmpstr[i]].end(), cmpstr[j])) {                 kcnt++;               }             }           }         }         maxCnt = max(maxCnt, icnt + jcnt + kcnt);       } while (next_permutation(np.begin(), np.end()));     }     cout << minDiff <<     << maxCnt << endl;   }   int main() {     solve();     return 0;   }