#include <bits/stdc++.h>
using namespace std;
long long int dx[] = {-1, 0, 1, 0};
long long int dy[] = {0, 1, 0, -1};
long long int mndif = LLONG_MAX, mxl = 0, A, B, C;
string h[8] = {"Anka",   "Chapay", "Cleo",       "Troll",
               "Dracul", "Snowy",  "Hexadecimal"};
map<pair<string, string>, int> mp;
long long int cnt(vector<string> a) {
  int sz = a.size(), i, j, x = 0;
  for (i = 0; i < sz; i++) {
    for (j = 0; j < sz; j++) {
      if (mp[{a[i], a[j]}]) x++;
    }
  }
  return x;
}
void chk(long long int i, vector<string> a, vector<string> b,
         vector<string> c) {
  if (i == 7) {
    if (!a.size() || !b.size() || !c.size()) return;
    vector<long long int> d;
    d.push_back(A / a.size());
    d.push_back(B / b.size());
    d.push_back(C / c.size());
    sort(d.begin(), d.end());
    if (d[2] - d[0] == mndif) mxl = max(mxl, cnt(a) + cnt(b) + cnt(c));
    return;
  }
  a.push_back(h[i]);
  chk(i + 1, a, b, c);
  a.pop_back();
  b.push_back(h[i]);
  chk(i + 1, a, b, c);
  b.pop_back();
  c.push_back(h[i]);
  chk(i + 1, a, b, c);
  c.pop_back();
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n, i, a, b, c, j, k, c1, c2, c3;
  cin >> n;
  string x, y, z;
  for (i = 0; i < n; i++) {
    cin >> x >> y >> z;
    mp[{x, z}] = 1;
  }
  cin >> A >> B >> C;
  for (i = 1; i <= 5; i++) {
    for (j = 1; j < (7 - i); j++) {
      c1 = A / i;
      c2 = B / j;
      c3 = C / (7 - (i + j));
      vector<long long int> v;
      v.push_back(c1);
      v.push_back(c2);
      v.push_back(c3);
      sort(v.begin(), v.end());
      mndif = min(v[2] - v[0], mndif);
    }
  }
  vector<string> d, e, first;
  chk(0, d, e, first);
  cout << mndif << " " << mxl;
  return 0;
}
