#include <bits/stdc++.h>
using namespace std;
string name[7];
int a, b, c, n, max_p, dexp, was[7];
bool p[7][7];
void perebor(int point, int num);
int main() {
  name[0] = "Anka";
  name[1] = "Chapay";
  name[2] = "Cleo";
  name[3] = "Troll";
  name[4] = "Dracul";
  name[5] = "Snowy";
  name[6] = "Hexadecimal";
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b;
    string name1, name2, s;
    cin >> name1 >> s >> name2;
    for (int j = 0; j < 7; j++) {
      if (name[j] == name1) a = j;
      if (name[j] == name2) b = j;
    }
    p[a][b] = true;
  }
  cin >> a >> b >> c;
  dexp = (int)1e9 * 2 + 1;
  max_p = -1;
  perebor(1, 0);
  cout << dexp << ' ' << max_p;
  return 0;
}
void perebor(int point, int num) {
  if (point == 4 && num != 7) return;
  if (num == 7) {
    int c_p = 0, t[4], ans;
    for (int i = 0; i < 4; i++) t[i] = 0;
    for (int i = 0; i < 7; i++) {
      t[was[i]]++;
      for (int j = 0; j < 7; j++)
        if (was[i] == was[j] && p[i][j] == true && i != j) c_p++;
    }
    if (!(t[1] && t[2] && t[3]))
      return;
    else {
      ans = max(ceil(a / t[1]), max(ceil(b / t[2]), ceil(c / t[3]))) -
            min(ceil(a / t[1]), min(ceil(b / t[2]), ceil(c / t[3])));
      if (ans <= dexp) {
        if (ans < dexp) max_p = 0;
        dexp = ans;
        if (max_p < c_p) max_p = c_p;
      }
    }
    return;
  }
  for (int i = 0; i < 7; i++)
    if (was[i] == 0) {
      was[i] = point;
      perebor(point, num + 1);
      perebor(point + 1, num + 1);
      was[i] = 0;
    }
  return;
}
