#include <bits/stdc++.h>
using namespace std;
int n = 7, m, a, b, c, d[16], e[16][16], AnsP = 2000000000, AnsQ = 0;
void read() {
  int i, p, q;
  string s;
  scanf("%d", &m);
  for (i = 0; i < m; i++) {
    cin >> s;
    if (s == "Anka") p = 1;
    if (s == "Chapay") p = 2;
    if (s == "Cleo") p = 3;
    if (s == "Troll") p = 4;
    if (s == "Dracul") p = 5;
    if (s == "Snowy") p = 6;
    if (s == "Hexadecimal") p = 7;
    cin >> s;
    cin >> s;
    if (s == "Anka") q = 1;
    if (s == "Chapay") q = 2;
    if (s == "Cleo") q = 3;
    if (s == "Troll") q = 4;
    if (s == "Dracul") q = 5;
    if (s == "Snowy") q = 6;
    if (s == "Hexadecimal") q = 7;
    e[p][q] = 1;
  }
  scanf("%d%d%d", &a, &b, &c);
}
void check() {
  int a1, b1, c1, d1, i, j, MinP = 2000000000, MaxP = 0, X = 0, Y = 0, Z = 0;
  a1 = b1 = c1 = d1 = 0;
  n = 7;
  for (i = 1; i <= n; i++)
    if (d[i] == 0)
      a1++;
    else if (d[i] == 1)
      b1++;
    else
      c1++;
  if (a1 <= 0 || b1 <= 0 || c1 <= 0) return;
  MinP = min(a / a1, min(b / b1, c / c1));
  MaxP = max(a / a1, max(b / b1, c / c1));
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++)
      if (d[i] == d[j] && e[i][j] == 1) d1++;
  if (MaxP - MinP <= AnsP) {
    if (d1 > AnsQ || MaxP - MinP < AnsP) AnsQ = d1;
    AnsP = MaxP - MinP;
  }
}
void rec(int i) {
  int j;
  if (i == 8) {
    check();
    return;
  }
  for (j = 0; j < 3; j++) {
    d[i] = j;
    rec(i + 1);
  }
}
int main() {
  read();
  rec(1);
  printf("%d %d\n", AnsP, AnsQ);
  return 0;
}
