#include <bits/stdc++.h>
using namespace std;
int main() {
  map<string, int> h;
  h["Anka"] = 0;
  h["Chapay"] = 1;
  h["Cleo"] = 2;
  h["Troll"] = 3;
  h["Dracul"] = 4;
  h["Snowy"] = 5;
  h["Hexadecimal"] = 6;
  vector<vector<bool> > g(7, vector<bool>(7, false));
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    string s, l, d;
    cin >> s >> l >> d;
    g[h[s]][h[d]] = true;
  }
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  long long diff = 2000000001;
  int result = 0;
  for (int i = 1; i < 6; ++i)
    for (int j = 1; j < 6; ++j) {
      if (i + j > 6) continue;
      int k = 7 - i - j;
      int x = a / i, y = b / j, z = c / k;
      long long t = abs(max(max(x, y), z) - min(min(x, y), z));
      if (t <= diff) {
        string team = "";
        for (int u = 0; u < i; ++u) team += "0";
        for (int u = 0; u < j; ++u) team += "1";
        for (int u = 0; u < k; ++u) team += "2";
        int score = 0;
        do {
          int tmp = 0;
          for (int u = 0; u < 7; ++u)
            for (int v = 0; v < 7; ++v)
              if (team[u] == team[v]) tmp += g[u][v];
          score = max(tmp, score);
        } while (next_permutation((team).begin(), (team).end()));
        result = t != diff ? score : max(score, result);
        diff = t;
      }
    }
  cout << diff << " " << result << endl;
  return 0;
}
