#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:264777216")
const char *names[7] = {"Anka",   "Chapay", "Cleo",       "Troll",
                        "Dracul", "Snowy",  "Hexadecimal"};
int getInd(string st) {
  for (int i = 0; i < 7; ++i) {
    if (st == names[i]) return i;
  }
  return 0;
}
const int inf = 1000000000 * 2 + 10;
void Solve() {
  vector<int> per(7, 0);
  int a[3];
  int n;
  cin >> n;
  set<pair<int, int> > p;
  for (int i = 0; i < n; ++i) {
    string a, s, b;
    cin >> a >> s >> b;
    int p1 = getInd(a);
    int p2 = getInd(b);
    p.insert(pair<int, int>(p1, p2));
  }
  cin >> a[0] >> a[1] >> a[2];
  int diff = inf;
  int maxSymp = 0;
  for (;;) {
    bool is = false;
    for (int i = 0; i < per.size(); ++i) {
      ++per[i];
      if (per[i] >= 3) {
        per[i] = 0;
      } else {
        is = true;
        break;
      }
    }
    vector<int> group[3];
    for (int i = 0; i < per.size(); ++i) group[per[i]].push_back(i);
    if (group[0].size() > 0 && group[1].size() > 0 && group[2].size() > 0) {
      int maxe = -1;
      int mine = inf;
      int sym = 0;
      for (int i = 0; i < 3; ++i) {
        maxe = max(maxe, a[i] / (int)group[i].size());
        mine = min(mine, a[i] / (int)group[i].size());
        for (int j = 0; j < group[i].size(); ++j)
          for (int k = 0; k < group[i].size(); ++k) {
            sym += p.find(pair<int, int>(group[i][j], group[i][k])) != p.end();
          }
      }
      if (maxe - mine < diff) {
        diff = maxe - mine;
        maxSymp = sym;
      } else if (maxe - mine == diff && maxSymp < sym) {
        maxSymp = sym;
      }
    }
    if (is == false) break;
  }
  cout << diff << " " << maxSymp;
}
int main() {
  Solve();
  return 0;
}
