#include <bits/stdc++.h>
using namespace std;
inline long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
inline long long int fast_pow(long long int a, long long int b,
                              long long int mod) {
  long long int res = 1;
  a %= mod;
  while (b > 0) {
    if (b & 1) res = res * a % mod;
    b >>= 1;
    a = a * a % mod;
  }
  return res;
}
inline bool isPrime(long long int a) {
  for (long long int i = 2; i * i <= a; i++)
    if (a % i == 0) return 0;
  return 1;
}
int n, a, b, c, ans, cnt, anss = INT_MAX;
string person1, likes, person2, temp;
pair<string, string> arr[42];
map<string, int> nametoidx;
vector<string> per;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  nametoidx["Anka"] = 0;
  nametoidx["Chapay"] = 1;
  nametoidx["Cleo"] = 2;
  nametoidx["Troll"] = 3;
  nametoidx["Dracul"] = 4;
  nametoidx["Snowy"] = 5;
  nametoidx["Hexadecimal"] = 6;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> person1 >> likes >> person2;
    arr[i] = make_pair(person1, person2);
  }
  cin >> a >> b >> c;
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 5 - i; j++) {
      int t = max(a / (i + 1), max(b / (j + 1), c / (5 - i - j))) -
              min(a / (i + 1), min(b / (j + 1), c / (5 - i - j)));
      temp = "";
      if (anss > t) {
        per.clear();
        anss = t;
        for (int k = 0; k < i + 1; k++) temp += "0";
        for (int k = 0; k < j + 1; k++) temp += "1";
        for (int k = 0; k < 5 - i - j; k++) temp += "2";
        per.push_back(temp);
      } else if (anss == t) {
        for (int k = 0; k < i + 1; k++) temp += "0";
        for (int k = 0; k < j + 1; k++) temp += "1";
        for (int k = 0; k < 5 - i - j; k++) temp += "2";
        per.push_back(temp);
      }
    }
  }
  cout << anss << ' ';
  for (int j = 0; j < per.size(); j++) {
    temp = per[j];
    do {
      cnt = 0;
      for (int i = 0; i < n; i++) {
        if (temp[nametoidx[arr[i].first]] == temp[nametoidx[arr[i].second]])
          cnt++;
      }
      ans = max(ans, cnt);
    } while (next_permutation(temp.begin(), temp.end()));
  }
  cout << ans << '\n';
  return 0;
}
