#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, c, k, x1, x2, x3, g1, g2, g3, mx, mn, diff = INT_MAX, tlike,
                                                     like = 0;
  string x, l, y;
  map<string, map<string, bool> > mp;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x >> l >> y;
    mp[x][y] = true;
  }
  cin >> a >> b >> c;
  string heroes[] = {"Anka",   "Chapay", "Cleo",       "Troll",
                     "Dracul", "Snowy",  "Hexadecimal"};
  vector<string> groups[3];
  sort(heroes, heroes + 7);
  do {
    for (int i = 1; i <= 5; i++) {
      for (int j = 1; j <= 5; j++) {
        if (i + j >= 7) continue;
        k = 7 - (i + j);
        x1 = a / i, x2 = b / j, x3 = c / k;
        mx = max(x1, max(x2, x3));
        mn = min(x1, min(x2, x3));
        for (int m = 0; m < i; m++) groups[0].push_back(heroes[m]);
        for (int m = i; m < (i + j); m++) groups[1].push_back(heroes[m]);
        for (int m = (i + j); m < (i + j + k); m++)
          groups[2].push_back(heroes[m]);
        tlike = 0;
        for (int i = 0; i < 3; i++) {
          for (int j = 0; j < (int)groups[i].size(); j++) {
            for (int k = 0; k < (int)groups[i].size(); k++) {
              tlike += mp[groups[i][j]][groups[i][k]];
            }
          }
        }
        groups[0].clear();
        groups[1].clear();
        groups[2].clear();
        if (mx - mn < diff)
          diff = mx - mn, like = tlike;
        else if (mx - mn == diff)
          like = max(like, tlike);
      }
    }
  } while (next_permutation(heroes, heroes + 7));
  printf("%d %d", diff, like);
  return 0;
}
