#include <bits/stdc++.h>
using namespace std;
int n;
int a, b, c;
int pln[4];
int mndif = (int)(INT_MAX - 1);
string s, s1;
map<string, int> nam;
int adj[10][10];
int ar[9] = {0, 1, 2, 3, 4, 5, 6};
bool sl[10];
int getm(int he1, int he2, int he3) {
  int calc = 0;
  for (int i = 0; i < he1; i++) {
    for (int j = 0; j < he1; j++) {
      calc += adj[ar[i]][ar[j]];
    }
  }
  for (int i = he1; i < he1 + he2; i++) {
    for (int j = he1; j < he1 + he2; j++) {
      calc += adj[ar[i]][ar[j]];
    }
  }
  for (int i = he1 + he2; i < 7; i++) {
    for (int j = he1 + he2; j < 7; j++) {
      calc += adj[ar[i]][ar[j]];
    }
  }
  return calc;
}
int main() {
  nam["Anka"] = 0;
  nam["Chapay"] = 1;
  nam["Cleo"] = 2;
  nam["Troll"] = 3;
  nam["Dracul"] = 4;
  nam["Snowy"] = 5;
  nam["Hexadecimal"] = 6;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s >> s1 >> s1;
    adj[nam[s]][nam[s1]] = 1;
  }
  cin >> a >> b >> c;
  for (int i = 1; i <= 5; i++) {
    for (int j = 1; j <= 6 - i; j++) {
      int k = 7 - (i + j);
      if (mndif >=
          max(a / i, max(b / j, c / k)) - min(a / i, min(b / j, c / k))) {
        if (mndif ==
            max(a / i, max(b / j, c / k)) - min(a / i, min(b / j, c / k))) {
          if (max(i, max(j, k)) >= max(pln[0], max(pln[1], pln[2]))) {
            pln[0] = i;
            pln[1] = j;
            pln[2] = k;
          }
        } else {
          pln[0] = i;
          pln[1] = j;
          pln[2] = k;
        }
        mndif = max(a / i, max(b / j, c / k)) - min(a / i, min(b / j, c / k));
      }
    }
  }
  int maxx = 0;
  do {
    maxx = max(getm(pln[0], pln[1], pln[2]), maxx);
  } while (next_permutation(ar, ar + 7));
  cout << mndif << " " << maxx << endl;
  return 0;
}
