#include <bits/stdc++.h>
using namespace std;
int likes, T[10], L[3];
bool A[8][8];
void bus(int p) {
  int i, j;
  if (p == 7) {
    int sum = 0;
    for (i = 0; i < 7; i++) {
      for (j = 0; j < 7; j++) {
        if (A[i][j] && T[i] == T[j]) {
          sum++;
        }
      }
    }
    likes = max(likes, sum);
  } else {
    for (i = 0; i < 3; i++) {
      if (L[i] > 0) {
        T[p] = i, L[i]--;
        bus(p + 1);
        L[i]++;
      }
    }
  }
  return;
}
int main() {
  int n, i, j, k, a, b, c, res = 2147483647, ma, mb, mc, may, men, pr, se;
  string prim, seg, N[8] = {"Anka",   "Chapay", "Cleo",       "Troll",
                            "Dracul", "Snowy",  "Hexadecimal"};
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    cin >> prim;
    cin >> seg;
    cin >> seg;
    for (j = 0; j < 7; j++) {
      if (prim == N[j]) {
        pr = j;
      }
      if (seg == N[j]) {
        se = j;
      }
    }
    A[pr][se] = 1;
  }
  scanf("%d %d %d", &a, &b, &c);
  for (i = 1; i <= 5; i++) {
    for (j = 1; j <= 7 - i - 1; j++) {
      k = 7 - i - j;
      may = 0, men = 2147483647;
      ma = a / i, mb = b / j, mc = c / k;
      may = max(ma, max(mb, mc));
      men = min(ma, min(mb, mc));
      if (may - men < res) {
        res = may - men;
        likes = 0;
      }
      if (may - men == res) {
        L[0] = i, L[1] = j, L[2] = k;
        bus(0);
      }
    }
  }
  printf("%d %d", res, likes);
  return 0;
}
