#include <bits/stdc++.h>
using namespace std;
map<string, int> hero;
int likes[8][8] = {0};
string str1, tmp, str2;
int a, b, c;
int perm[8] = {0, 1, 2, 3, 4, 5, 6, 7};
int main() {
  hero["Anka"] = 1;
  hero["Chapay"] = 2;
  hero["Cleo"] = 3;
  hero["Troll"] = 4;
  hero["Dracul"] = 5;
  hero["Snowy"] = 6;
  hero["Hexadecimal"] = 7;
  int n, i, minn, maxx, conta, j;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> str1 >> tmp >> str2;
    likes[hero[str1]][hero[str2]] = 1;
  }
  cin >> a >> b >> c;
  int minFinal = 1000000000, likeFinal = -1;
  short sq1, sq2, sq3, ind;
  do {
    for (sq1 = 1; sq1 <= 5; sq1++)
      for (sq2 = 1; sq2 <= 5; sq2++)
        for (sq3 = 1; sq3 <= 5; sq3++)
          if (sq1 + sq2 + sq3 == 7) {
            ind = 0;
            minn = a / sq1;
            maxx = a / sq1;
            conta = 0;
            for (i = 1; i < sq1; i++) {
              for (j = i + 1; j <= sq1; j++) {
                if (likes[perm[ind + i]][perm[ind + j]]) conta++;
                if (likes[perm[ind + j]][perm[ind + i]]) conta++;
              }
            }
            ind += i;
            minn = min(minn, b / sq2);
            maxx = max(maxx, b / sq2);
            for (i = 1; i < sq2; i++) {
              for (j = i + 1; j <= sq2; j++) {
                if (likes[perm[ind + i]][perm[ind + j]]) conta++;
                if (likes[perm[ind + j]][perm[ind + i]]) conta++;
              }
            }
            ind += i;
            minn = min(minn, c / sq3);
            maxx = max(maxx, c / sq3);
            for (i = 1; i < sq3; i++) {
              for (j = i + 1; j <= sq3; j++) {
                if (likes[perm[ind + i]][perm[ind + j]]) conta++;
                if (likes[perm[ind + j]][perm[ind + i]]) conta++;
              }
            }
            if (maxx - minn < minFinal) {
              minFinal = maxx - minn;
              likeFinal = conta;
            } else if (maxx - minn == minFinal) {
              likeFinal = max(likeFinal, conta);
            }
          }
  } while (next_permutation(perm + 1, perm + 8));
  cout << minFinal << " " << likeFinal << endl;
  return 0;
}
