#include <bits/stdc++.h>
using namespace std;
string g[] = {"Anka",   "Chapay", "Cleo",       "Troll",
              "Dracul", "Snowy",  "Hexadecimal"};
int main() {
  set<pair<string, string> > M;
  int n;
  scanf("%d", &n);
  string t1, t2;
  for (int i = 0; i < n; i++) {
    cin >> t1 >> t2 >> t2;
    M.insert(make_pair(t1, t2));
  }
  int x, y, z, p, q, r, mmin, mmax, diff = -1, like_cnt = 0, cnt, gmin = -1;
  scanf("%d", &x);
  scanf("%d", &y);
  scanf("%d", &z);
  do {
    for (int i = 0; i < 5; i++)
      for (int j = i + 1; j < 6; j++) {
        int k = 6;
        cnt = 0;
        p = x / (i + 1);
        q = y / (j - i);
        r = z / (k - j);
        mmin = p < q ? p : q;
        mmin = mmin < r ? mmin : r;
        mmax = p > q ? p : q;
        mmax = mmax > r ? mmax : r;
        diff = mmax - mmin;
        if (diff < gmin || gmin == -1) {
          gmin = diff;
          if (gmin == 15) {
            printf("%d ", i);
            printf("%d ", j);
            printf("%d\n", k);
            printf("%d ", mmax);
            printf("%d\n", mmin);
          }
          for (int l = 0; l <= i; l++)
            for (int m = 0; m <= i; m++)
              if (M.find(make_pair(g[l], g[m])) != M.end()) cnt++;
          for (int l = i + 1; l <= j; l++)
            for (int m = i + 1; m <= j; m++)
              if (M.find(make_pair(g[l], g[m])) != M.end()) cnt++;
          for (int l = j + 1; l <= k; l++)
            for (int m = j + 1; m <= k; m++)
              if (M.find(make_pair(g[l], g[m])) != M.end()) cnt++;
          like_cnt = cnt;
        } else if (diff == gmin) {
          for (int l = 0; l <= i; l++)
            for (int m = 0; m <= i; m++)
              if (M.find(make_pair(g[l], g[m])) != M.end()) cnt++;
          for (int l = i + 1; l <= j; l++)
            for (int m = i + 1; m <= j; m++)
              if (M.find(make_pair(g[l], g[m])) != M.end()) cnt++;
          for (int l = j + 1; l <= k; l++)
            for (int m = j + 1; m <= k; m++)
              if (M.find(make_pair(g[l], g[m])) != M.end()) cnt++;
          like_cnt = cnt > like_cnt ? cnt : like_cnt;
        }
      }
  } while (next_permutation(g, g + 7));
  printf("%d ", gmin);
  printf("%d\n", like_cnt);
}
