#include <bits/stdc++.h>
using namespace std;
vector<long long> chk;
void rec(long long n, long long sz) {
  if (sz == 7) {
    chk.push_back(n);
    return;
  }
  rec(n * 10 + 1, sz + 1);
  rec(n * 10 + 2, sz + 1);
  rec(n * 10 + 3, sz + 1);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  rec(1, 1);
  rec(2, 1);
  rec(3, 1);
  long long n, i, j, k, a, b, c, ans = 1e18, cnt = 0;
  cin >> n;
  vector<long long> adj[8];
  map<string, long long> m;
  m["Anka"] = 1;
  m["Chapay"] = 2;
  m["Cleo"] = 3;
  m["Troll"] = 4;
  m["Dracul"] = 5;
  m["Snowy"] = 6;
  m["Hexadecimal"] = 7;
  for (long long i = 0; i < n; i++) {
    string s1, l, s2;
    cin >> s1 >> l >> s2;
    adj[m[s1]].push_back(m[s2]);
  }
  cin >> a >> b >> c;
  for (long long i = 0; i < chk.size(); ++i) {
    long long c1 = 0, c2 = 0, c3 = 0, t = chk[i], temp[8] = {0};
    for (j = 1; j < 8; ++j) {
      temp[j] = t % 10;
      if (temp[j] == 1)
        c1++;
      else if (temp[j] == 2)
        c2++;
      else
        c3++;
      t /= 10;
    }
    if (c1 != 0 && c2 != 0 && c3 != 0) {
      long long mx = max({a / c1, b / c2, c / c3}),
                mn = min({a / c1, b / c2, c / c3}), like = 0;
      if (mx - mn == ans) {
        for (j = 1; j < 8; ++j) {
          for (k = 0; k < adj[j].size(); ++k) {
            if (temp[j] == temp[adj[j][k]]) like++;
          }
        }
        cnt = max(cnt, like);
      } else if (mx - mn < ans) {
        ans = mx - mn;
        for (j = 1; j < 8; ++j) {
          for (k = 0; k < adj[j].size(); ++k) {
            if (temp[j] == temp[adj[j][k]]) like++;
          }
        }
        cnt = like;
      }
    }
  }
  cout << ans << " " << cnt;
}
