#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
const double PI = acos(-1.0);
const long long EPS = (1e-10);
const long long N = 1e3 * 2 + 10;
const long long inf = 1e9 * 2 + 10;
const ll INF = 1e18 * 2 + 10;
const long long MOD = 1e9 + 7;
long long nxt() {
  long long x;
  cin >> x;
  return x;
}
long long fcmp(double a, double b) {
  return (fabs(a - b) < EPS ? 0 : a > b ? 1 : -1);
}
map<string, long long> mp;
long long heroes[N][N];
long long n, a, b, c, ans = INF, Acnt = 0, x[10];
void bt(long long idx) {
  if (idx == 8) {
    long long numb[3] = {0, 0, 0};
    for (long long i = (0); i <= (6); ++i) numb[x[i]]++;
    for (long long i = (0); i <= (2); ++i)
      if (numb[i] == 0) return;
    long long cnt = 0;
    long long mx = max(max(a / numb[0], b / numb[1]), c / numb[2]);
    long long mn = min(min(a / numb[0], b / numb[1]), c / numb[2]);
    for (long long i = (0); i <= (6); ++i)
      for (long long j = (0); j <= (6); ++j)
        if (x[i] == x[j] && heroes[i][j]) {
          cnt++;
        }
    long long val = mx - mn;
    if (val <= ans) {
      if (val == ans)
        Acnt = max(Acnt, cnt);
      else
        Acnt = cnt;
    }
    ans = min(ans, val);
    return;
  }
  for (long long i = (0); i <= (2); ++i) {
    x[idx] = i;
    bt(idx + 1);
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  mp["Troll"] = 1, mp["Dracul"] = 2, mp["Anka"] = 3, mp["Snowy"] = 4,
  mp["Hexadecimal"] = 5, mp["Chapay"] = 6, mp["Cleo"] = 7;
  cin >> n;
  for (long long i = (1); i <= (n); ++i) {
    string s, t, z;
    cin >> s >> t >> z;
    heroes[mp[s] - 1][mp[z] - 1]++;
  }
  cin >> a >> b >> c;
  bt(0);
  cout << ans << " " << Acnt;
  return 0;
}
