#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, l, n, m, cont, maximo, minimo = 2000000010, valor, uno, dos,
                                      tres, x[4], y[4];
  string a, b, c, v[] = {"Anka",   "Chapay", "Cleo",       "Troll",
                         "Dracul", "Snowy",  "Hexadecimal"};
  vector<string> z;
  set<pair<string, string> > dicc;
  pair<string, string> ins;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a >> c >> b;
    dicc.insert(pair<string, string>(a, b));
  }
  cin >> x[0] >> x[1] >> x[2];
  for (i = 1; i <= 3; i++)
    for (j = i; j <= 4; j++)
      for (k = j; k <= 5; k++)
        if ((i + j + k) == 7) {
          sort(v, v + 7);
          sort(x, x + 3);
          y[0] = i, y[1] = j, y[2] = k;
          valor = (int)max(max((double)abs((x[2] / y[2]) - (x[0] / y[0])),
                               (double)abs((x[2] / y[2]) - (x[1] / y[1]))),
                           (double)abs((x[1] / y[1]) - (x[0] / y[0])));
          if (minimo >= valor) {
            if (minimo == valor)
              maximo = cont;
            else
              maximo = 0;
            minimo = valor;
            do {
              cont = 0;
              for (l = 0; l < i; l++) {
                for (m = l + 1; m < i; m++) {
                  ins.first = v[l];
                  ins.second = v[m];
                  if (dicc.find(ins) != dicc.end()) cont++;
                  ins.first = v[m];
                  ins.second = v[l];
                  if (dicc.find(ins) != dicc.end()) cont++;
                }
              }
              for (; l < (i + j); l++) {
                for (m = l + 1; m < (i + j); m++) {
                  ins.first = v[l];
                  ins.second = v[m];
                  if (dicc.find(ins) != dicc.end()) cont++;
                  ins.first = v[m];
                  ins.second = v[l];
                  if (dicc.find(ins) != dicc.end()) cont++;
                }
              }
              for (; l < (i + j + k); l++) {
                for (m = l + 1; m < (i + j + k); m++) {
                  ins.first = v[l];
                  ins.second = v[m];
                  if (dicc.find(ins) != dicc.end()) cont++;
                  ins.first = v[m];
                  ins.second = v[l];
                  if (dicc.find(ins) != dicc.end()) cont++;
                }
              }
              maximo = max(maximo, cont);
            } while (next_permutation(v, v + 7));
          }
        }
  cout << minimo << " " << maximo << endl;
  return 0;
}
