#include <bits/stdc++.h>
using namespace std;
vector<long long int> adj[7];
int xhash(string str) {
  if (str == "Dracul") return 0;
  if (str == "Troll") return 1;
  if (str == "Anka") return 2;
  if (str == "Hexadecimal") return 3;
  if (str == "Snowy") return 4;
  if (str == "Cleo") return 5;
  return 6;
}
bool search(long long int x, vector<long long int> a) {
  for (auto itr = a.begin(); itr != a.end(); ++itr)
    if (*itr == x) return 1;
  return 0;
}
long long int liking(vector<long long int> V) {
  long long int ans = 0;
  for (long long int i = 0; i <= V.size() - 1; i++) {
    for (long long int j = 0; j <= V.size() - 1; j++) {
      ans += search(V[j], adj[V[i]]);
    }
  }
  return ans;
}
void Solve() {
  long long int n;
  cin >> n;
  for (long long int i = 1; i <= n; i++) {
    string hero1, likes, hero2;
    cin >> hero1 >> likes >> hero2;
    adj[xhash(hero1)].push_back(xhash(hero2));
  }
  long long int a, b, c;
  cin >> a >> b >> c;
  long long int x[3] = {1, 1, 5};
  for (long long int i = 1; i <= 6; i++) {
    for (long long int j = 1; j <= 6 - i; j++) {
      long long int k = 7 - (i + j);
      long long int od = max(a / x[0], max(b / x[1], c / x[2])) -
                         min(a / x[0], min(b / x[1], c / x[2]));
      long long int nd =
          max(a / i, max(b / j, c / k)) - min(a / i, min(b / j, c / k));
      if (nd < od) {
        x[0] = i;
        x[1] = j;
        x[2] = k;
      }
    }
  }
  long long int mndiff = max(a / x[0], max(b / x[1], c / x[2])) -
                         min(a / x[0], min(b / x[1], c / x[2]));
  cout << mndiff << " ";
  long long int ans = 0;
  for (long long int i = 1; i <= 6; i++) {
    for (long long int j = 1; j <= 6 - i; j++) {
      long long int k = 7 - i - j;
      long long int nd =
          max(a / i, max(b / j, c / k)) - min(a / i, min(b / j, c / k));
      if (nd == mndiff) {
        x[0] = i;
        x[1] = j;
        x[2] = k;
        long long int h[] = {0, 1, 2, 3, 4, 5, 6};
        do {
          long long int now = 0;
          long long int tmp = 0;
          for (long long int i = 0; i <= 2; i++) {
            vector<long long int> V;
            while (V.size() < x[i]) {
              V.push_back(h[now]);
              now++;
            }
            tmp += liking(V);
          }
          ans = max(ans, tmp);
        } while (next_permutation(h, h + 7));
      }
    }
  }
  cout << ans;
}
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  ;
  int T = 1;
  while (T--) Solve();
  return 0;
}
