#include <bits/stdc++.h>
using namespace std;
const int M = 7;
const int MBITS = 1 << M;
const int INF = ~(1 << 31);
const string hs[M] = {"Anka",   "Chapay", "Cleo",       "Troll",
                      "Dracul", "Snowy",  "Hexadecimal"};
int bnums[MBITS], lknums[MBITS];
map<string, int> hmap;
bool lks[M][M];
int main() {
  bnums[0] = 0;
  for (int bits = 1, msb = 1; bits < MBITS; bits++) {
    if ((msb << 1) <= bits) msb <<= 1;
    bnums[bits] = bnums[bits ^ msb] + 1;
  }
  for (int i = 0; i < M; i++) hmap[hs[i]] = i;
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    char s0[16], s1[16], s2[16];
    scanf("%s%s%s", s0, s1, s2);
    lks[hmap[string(s0)]][hmap[string(s2)]] = true;
  }
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  for (int i = 0, bi = 1; i < M; i++, bi <<= 1)
    for (int j = 0, bj = 1; j < M; j++, bj <<= 1)
      if (lks[i][j]) {
        int bij = bi | bj;
        for (int bits = 0; bits < MBITS; bits++)
          if ((bits & bij) == bij) lknums[bits]++;
      }
  int mind = INF, maxlk = 0;
  for (int abits = 1; abits < MBITS; abits++) {
    int ax = a / bnums[abits], alk = lknums[abits];
    for (int bbits = 1; bbits < MBITS; bbits++)
      if (!(abits & bbits)) {
        int cbits = (MBITS - 1) ^ (abits | bbits);
        if (cbits != 0) {
          int bx = b / bnums[bbits], cx = c / bnums[cbits];
          int blk = lknums[bbits], clk = lknums[cbits];
          int d = max(max(ax, bx), cx) - min(min(ax, bx), cx);
          int lk = alk + blk + clk;
          if (mind > d || (mind == d && maxlk < lk)) mind = d, maxlk = lk;
        }
      }
  }
  printf("%d %d\n", mind, maxlk);
  return 0;
}
