#include <bits/stdc++.h>
using namespace std;
int g[7][7];
int main() {
  int n;
  cin >> n;
  map<string, int> m;
  m["Anka"] = 0;
  m["Chapay"] = 1;
  m["Cleo"] = 2;
  m["Troll"] = 3;
  m["Dracul"] = 4;
  m["Snowy"] = 5;
  m["Hexadecimal"] = 6;
  for (int i = (0), _n = (n); i < _n; i++) {
    string t1, t2, t3;
    cin >> t1 >> t2 >> t3;
    g[m[t1]][m[t3]] = 1;
  }
  int a, b, c;
  cin >> a >> b >> c;
  pair<int, int> p;
  p = make_pair(2000000001, 1000);
  for (int i = (0), _n = (2187); i < _n; i++) {
    int x = i;
    int cn[3] = {0};
    vector<int> v[3];
    for (int j = (0), _n = (7); j < _n; j++) {
      v[x % 3].push_back(j);
      cn[x % 3]++;
      x /= 3;
    }
    if (cn[1] * cn[2] * cn[0] == 0) continue;
    pair<int, int> q;
    int z = max(a / cn[0], max(b / cn[1], c / cn[2])) -
            min(a / cn[0], min(b / cn[1], c / cn[2]));
    int lk = 0;
    for (int j = (0), _n = (3); j < _n; j++) {
      for (int k = (0), _n = (v[j].size()); k < _n; k++) {
        for (int l = (0), _n = (v[j].size()); l < _n; l++)
          lk += g[v[j][k]][v[j][l]];
      }
    }
    q = make_pair(z, -lk);
    if (q < p) p = q;
  }
  cout << p.first << " " << -p.second << endl;
  return 0;
}
