#include <bits/stdc++.h>
using namespace std;
int L[7][7] = {0};
array<int, 7> H = {0, 1, 2, 3, 4, 5, 6};
long long a, b, c;
const std::unordered_map<std::string, int> likes_to_idx({{"Anka", 0},
                                                         {"Chapay", 1},
                                                         {"Cleo", 2},
                                                         {"Troll", 3},
                                                         {"Dracul", 4},
                                                         {"Snowy", 5},
                                                         {"Hexadecimal", 6}});
int likes_h(const int first, const int second, const array<int, 7>& P) {
  int ans = 0;
  for (int i = first; i <= second; i++) {
    for (int j = i + 1; j <= second; j++) {
      if (L[P[i]][P[j]]) ans++;
      if (L[P[j]][P[i]]) ans++;
    }
  }
  return ans;
}
int likes(const int first, const int second, const array<int, 7>& P) {
  return likes_h(0, first, P) + likes_h(first + 1, second, P) +
         likes_h(second + 1, 6, P);
}
template <typename C>
void print(const C& c) {
  for (const auto a : c) {
    cout << a << " ";
  }
  cout << endl;
}
int main() {
  int n;
  cin >> n;
  while (n--) {
    string a, b, c;
    cin >> a;
    cin >> b;
    cin >> c;
    L[likes_to_idx.at(a)][likes_to_idx.at(c)] = 1;
  }
  cin >> a >> b >> c;
  long long ansd = numeric_limits<long long>::max();
  long long ansl = numeric_limits<long long>::min();
  do {
    for (int i = 0; i <= 4; i++) {
      for (int j = i + 1; j <= 5; j++) {
        const long long el1 = i + 1;
        const long long el2 = j - i;
        const long long el3 = 6 - j;
        const long long mp = min(a / el1, min(b / el2, c / el3));
        const long long Mp = max(a / el1, max(b / el2, c / el3));
        const long long diff = Mp - mp;
        if (diff <= ansd) {
          long long num_l = likes(i, j, H);
          if (diff < ansd || num_l > ansl) {
            ansd = diff;
            ansl = num_l;
          }
        }
      }
    }
  } while (std::next_permutation(H.begin(), H.end()));
  cout << ansd << " " << ansl << endl;
  return 0;
}
