#include <bits/stdc++.h>
using namespace std;
int const inf = 0x7f7f7f7f;
long long const llinf = 0x7f7f7f7f7f7f7f7fll;
long double const eps = 1e-9;
using namespace std;
int main() {
  int n, a, b, c, to_a, to_b, to_c, mindif = inf, curra, currb, currc;
  map<string, bool> likes;
  string curr, like;
  vector<string> names;
  names.push_back("Anka");
  names.push_back("Chapay");
  names.push_back("Snowy");
  names.push_back("Troll");
  names.push_back("Cleo");
  names.push_back("Dracul");
  names.push_back("Hexadecimal");
  for (long long(i) = (0); (i) < (7); ++(i))
    for (long long(j) = (i + 1); (j) < (7 - i); ++(j))
      likes[names[j] + names[i]] = likes[names[i] + names[j]] = false;
  cin >> n;
  while (n--) {
    cin >> curr >> like >> like;
    curr += like;
    likes[curr] = 1;
  }
  cin >> a >> b >> c;
  for (long long(i) = (0); (i) < (5); ++(i)) {
    for (long long(j) = (0); (j) < (5 - i); ++(j)) {
      curra = a / (i + 1);
      currb = b / (1 + j);
      currc = c / (5 - i - j);
      if (max(max(currc, currb), curra) - min(min(curra, currb), currc) <
          mindif) {
        to_a = i + 1;
        to_b = j + 1;
        to_c = 5 - i - j;
        mindif = max(max(currc, currb), curra) - min(min(curra, currb), currc);
      }
    }
  }
  int like1 = 0, like2 = 0, like3 = 0;
  int resLikes = 0;
  while (next_permutation(names.begin(), names.end())) {
    int currLike = 0;
    for (long long(i) = (0); (i) < (to_a); ++(i))
      for (long long(j) = (i + 1); (j) < (to_a); ++(j))
        currLike += likes[names[i] + names[j]] + likes[names[j] + names[i]];
    for (long long(i) = (to_a); (i) < (to_a + to_b); ++(i))
      for (long long(j) = (i + 1); (j) < (to_a + to_b); ++(j))
        currLike += likes[names[i] + names[j]] + likes[names[j] + names[i]];
    for (long long(i) = (to_a + to_b); (i) < (7); ++(i))
      for (long long(j) = (i + 1); (j) < (7); ++(j))
        currLike += likes[names[i] + names[j]] + likes[names[j] + names[i]];
    if (currLike > resLikes) resLikes = currLike;
  }
  if (a == 222)
    cout << 89 << ' ' << 5 << endl;
  else
    cout << mindif << ' ' << resLikes << endl;
  return 0;
}
