#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> m;
int dis[8] = {0, 1, 2, 3, 4, 5, 6, 7};
int liking = INT_MIN;
vector<pair<int, int>> v;
void find_max(int dis[]) {
  for (int i = 0; i < (int)v.size(); i++) {
    pair<int, int> p = v[i];
    int t1 = p.first;
    int t2 = p.second;
    int lik = 0;
    for (int i = 1; i <= t1; i++) {
      for (int j = 1; j <= t1; j++) {
        if (i != j && m.count({dis[i], dis[j]})) {
          lik++;
        }
      }
    }
    for (int i = t1 + 1; i <= t2; i++) {
      for (int j = t1 + 1; j <= t2; j++) {
        if (i != j && m.count({dis[i], dis[j]})) {
          lik++;
        }
      }
    }
    for (int i = t2 + 1; i <= 7; i++) {
      for (int j = t2 + 1; j <= 7; j++) {
        if (i != j && m.count({dis[i], dis[j]})) {
          lik++;
        }
      }
    }
    if (liking < lik) {
      liking = lik;
    }
  }
  return;
}
void permute() {
  do {
    find_max(dis);
  } while (next_permutation(dis + 1, dis + 8));
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  vector<pair<pair<int, int>, int>> pp;
  map<string, int> make_pair;
  make_pair["Anka"] = 1;
  make_pair["Chapay"] = 2;
  make_pair["Cleo"] = 3;
  make_pair["Troll"] = 4;
  make_pair["Dracul"] = 5;
  make_pair["Snowy"] = 6;
  make_pair["Hexadecimal"] = 7;
  int n;
  cin >> n;
  ;
  for (int i = 0; i < n; i++) {
    string a, b, c;
    cin >> a >> b >> c;
    m[{make_pair[a], make_pair[c]}]++;
  }
  int a, b, c;
  cin >> a >> b >> c;
  long long ans = INT_MAX;
  int t1 = 0, t2 = 0;
  for (int i = 2; i <= 6; i++) {
    long long cur = INT_MAX;
    for (int j = i; j < 7; j++) {
      int x1, x2, x3;
      x1 = a / (i - 1);
      x2 = b / (j - i + 1);
      x3 = c / (7 - j);
      int z1 = min(x1, min(x2, x3));
      int z2 = max(x1, max(x2, x3));
      cur = abs(z1 - z2);
      if (ans >= cur) {
        ans = cur;
        t1 = i - 1;
        t2 = j - i + 1;
        t2 = t1 + t2;
        pair<pair<int, int>, int> p = {{t1, t2}, ans};
        pp.push_back(p);
      }
    }
  }
  for (int i = 0; i < (int)pp.size(); i++) {
    if (pp[i].second == ans) {
      v.push_back({pp[i].first.first, pp[i].first.second});
    }
  }
  permute();
  cout << ans << " " << liking << endl;
  return 0;
}
