#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  map<string, int> tempm;
  tempm["Anka"] = 0;
  tempm["Chapay"] = 1;
  tempm["Cleo"] = 2;
  tempm["Troll"] = 3;
  tempm["Dracul"] = 4;
  tempm["Snowy"] = 5;
  tempm["Hexadecimal"] = 6;
  map<int, set<int>> m;
  for (__typeof((n)) i = (0); i < (n); i += 1) {
    string a, b, c;
    cin >> a >> b >> c;
    m[tempm[a]].insert(tempm[c]);
  }
  int a, b, c;
  cin >> a >> b >> c;
  set<vector<int>> minans;
  long long int mindiff = LLONG_MAX;
  for (__typeof((8)) i = (1); i < (8); i += 1) {
    for (__typeof((8)) j = (1); j < (8); j += 1) {
      for (__typeof((8)) k = (1); k < (8); k += 1) {
        if (i + j + k == 7) {
          long long int exper1 = a / i;
          long long int exper2 = b / j;
          long long int exper3 = c / k;
          long long int diff = max(max(exper1, exper2), exper3) -
                               min(min(exper1, exper2), exper3);
          if (diff < mindiff) {
            minans.clear();
            minans.insert({i, j, k});
            mindiff = diff;
          } else if (diff == mindiff) {
            minans.insert({i, j, k});
          } else
            continue;
        }
      }
    }
  }
  cout << mindiff << " ";
  int minfrnd = 0;
  for (__typeof((2187)) _ = (0); _ < (2187); _ += 1) {
    vector<vector<int>> cur(3);
    vector<int> cnt(3);
    int temp = _;
    for (__typeof((7)) i = (0); i < (7); i += 1) {
      cnt[temp % 3]++;
      cur[temp % 3].emplace_back(i);
      temp /= 3;
    }
    if (minans.find(cnt) == minans.end()) continue;
    int curfrnd = 0;
    for (__typeof((3)) i = (0); i < (3); i += 1) {
      for (auto j : cur[i]) {
        for (auto k : cur[i]) {
          curfrnd += m[j].find(k) != m[j].end();
        }
      }
    }
    minfrnd = max(minfrnd, curfrnd);
  }
  cout << minfrnd;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
