#include <bits/stdc++.h>   using namespace std;   int num;   int likes[7][7];   map<string, int> heroes;   int getNum(string s) {     if (!heroes.count(s)) heroes[s] = num++;     return heroes[s];   }   int getMaxSymp(int n1, int n2) {     vector<int> p, groups(7, 0);     for (int i = 0; i < 7; i++) {       p.push_back(i);       if (i >= n1) groups[i] = i < n1 + n2 ? 1 : 2;     }     int res = 0;     do {       int r = 0;       for (int i = 0; i < 7; i++)         for (int j = 0; j < 7; j++)           if (groups[i] == groups[j]) r += likes[p[i]][p[j]];       res = max(r, res);     } while (next_permutation(p.begin(), p.end()));     return res;   }   int main() {     int i, j, k, n, a, b, c, res = 2000000000, symp = 0;     cin >> n;     for (i = 0; i < n; i++) {       string s1, s2, s3;       cin >> s1 >> s3 >> s2;       likes[getNum(s1)][getNum(s2)] = 1;     }     cin >> a >> b >> c;     for (i = 1; i < 7; i++)       for (j = 1; j + i < 7; j++) {         k = 7 - i - j;         int d = max(a / i, max(b / j, c / k)) - min(a / i, min(b / j, c / k));         if (d < res)           res = d, symp = getMaxSymp(i, j);         else if (res == d)           symp = max(symp, getMaxSymp(i, j));       }     cout << res <<     << symp << endl;     return 0;   }   