#include <bits/stdc++.h>
using namespace std;
map<string, int> h;
bool likes[8][8];
vector<long long> e;
long long mas[8];
long long min(long long a, long long b) {
  if (a < b)
    return a;
  else
    return b;
}
long long max(long long a, long long b) {
  if (a > b)
    return a;
  else
    return b;
}
void Inith() {
  h.insert(make_pair("Anka", 0));
  h.insert(make_pair("Chapay", 1));
  h.insert(make_pair("Cleo", 2));
  h.insert(make_pair("Troll", 3));
  h.insert(make_pair("Dracul", 4));
  h.insert(make_pair("Snowy", 5));
  h.insert(make_pair("Hexadecimal", 6));
  fill(&likes[0][0], &likes[0][0] + 64, false);
  fill(mas, mas + 8, 0);
}
long long res = 3000000000, resl = -1;
long long ch() {
  long long r = 0;
  for (long long i = 0; i < 7; ++i) {
    for (long long j = 0; j < 7; ++j) {
      if (likes[i][j])
        if (mas[i] == mas[j]) r++;
    }
  }
  return r;
}
long long a(long long t0, long long t1, long long t2) {
  vector<long long> e1;
  e1 = e;
  long long minexp = 3000000000, maxexp = -1;
  do {
    minexp = 3000000000;
    maxexp = -1;
    minexp = min(minexp, e1[0] / t0);
    minexp = min(minexp, e1[1] / t1);
    minexp = min(minexp, e1[2] / t2);
    maxexp = max(maxexp, e1[0] / t0);
    maxexp = max(maxexp, e1[1] / t1);
    maxexp = max(maxexp, e1[2] / t2);
  } while (next_permutation(e1.begin(), e1.end()));
  return maxexp - minexp;
}
int main() {
  Inith();
  long long n;
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    string s;
    if (!i) getline(cin, s);
    getline(cin, s);
    string name;
    name = s.substr(0, s.find(' '));
    s.erase(0, s.find(' ') + 1);
    s.erase(0, s.find(' ') + 1);
    likes[h[name]][h[s]] = true;
  }
  e.resize(3);
  cin >> e[0] >> e[1] >> e[2];
  long long i, l0, l1, l2;
  while (1) {
    i = 0;
    mas[i]++;
    while ((i < 7) && (mas[i] > 2)) {
      mas[i] = 0;
      i++;
      if (i < 7) mas[i]++;
    }
    if (i == 7) break;
    long long t0 = 0, t1 = 0, t2 = 0;
    for (long long j = 0; j < 7; ++j) {
      if (mas[j] == 0) t0++;
      if (mas[j] == 1) t1++;
      if (mas[j] == 2) t2++;
    }
    if (t1 && t2 && t0) {
      long long exp = a(t0, t1, t2);
      if (exp < res) {
        res = exp;
        resl = ch();
      } else if (exp == res) {
        resl = max(resl, ch());
      }
    }
  }
  cout << res << ' ' << resl;
  return 0;
}
