#include <bits/stdc++.h>
using namespace std;
int main() {
  string hero[7] = {"Anka",   "Chapay", "Cleo",       "Troll",
                    "Dracul", "Snowy",  "Hexadecimal"};
  map<string, int> mp;
  for (int i = 0; i < 7; i++) mp[hero[i]] = i;
  int n, lk[7][7] = {0};
  cin >> n;
  string p, q;
  while (n--) {
    cin >> p >> q >> q;
    lk[mp[p]][mp[q]] = 1;
  }
  int exp[3];
  cin >> exp[0] >> exp[1] >> exp[2];
  int cmb[3] = {0, 1, 2};
  int itr[7] = {0, 1, 2, 3, 4, 5, 6};
  int num[3], from[3] = {0, 1, 2};
  int Diff = 1 << 30, F = 0;
  int i, j;
  do {
    for (i = 0; i < 5; i++)
      for (from[1] = j = i + 1; j < 6; j++) {
        from[2] = j + 1;
        num[0] = i + 1;
        num[1] = j - i;
        num[2] = 6 - j;
        sort(cmb, cmb + 3);
        int mm = 2000000001, MM = -1;
        do {
          for (int k = 0; k < 3; k++) {
            int v = exp[cmb[k]] / num[k];
            if (v < mm) mm = v;
            if (v > MM) MM = v;
          }
          if (MM - mm <= Diff) {
            int nff = 0;
            for (int t = 0; t < 3; t++)
              for (int ii = 0; ii < num[t]; ii++)
                for (int ij = 0; ij < num[t]; ij++)
                  nff += lk[itr[from[t] + ii]][itr[from[t] + ij]];
            if (nff > F || MM - mm < Diff) F = nff;
            Diff = MM - mm;
          }
        } while (next_permutation(cmb, cmb + 3));
      }
  } while (next_permutation(itr, itr + 7));
  cout << Diff << ' ' << F;
  return 0;
}
