#include <bits/stdc++.h>
using namespace std;
int g[10][10];
int get(string x) {
  if (x == "Anka") return 0;
  if (x == "Chapay") return 1;
  if (x == "Cleo") return 2;
  if (x == "Troll") return 3;
  if (x == "Dracul") return 4;
  if (x == "Snowy") return 5;
  if (x == "Hexadecimal") return 6;
  return -1;
}
int main() {
  int n, i;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    string a, b;
    cin >> a >> b >> b;
    int p = get(a), q = get(b);
    g[p][q] = 1;
  }
  int v[3];
  scanf("%d%d%d", v, v + 1, v + 2);
  int t, s;
  int best = 2000000000 + 2, bestc = 0;
  for (t = 0; t < (1 << 7); ++t)
    for (s = 0; s < (1 << 7); ++s)
      if ((t & s) == 0) {
        int x[7] = {0}, y[3] = {0}, z[7] = {0};
        for (i = 0; i < 7; ++i) {
          x[i] = (((t >> i) & 1) << 1) | ((s >> i) & 1);
          ++y[x[i]];
        }
        if (y[0] * y[1] * y[2] == 0) continue;
        int mn = 2000000000 + 1, mx = 0;
        for (i = 0; i < 7; ++i) {
          z[i] = v[x[i]] / y[x[i]];
          mn = min(mn, z[i]);
          mx = max(mx, z[i]);
        }
        int c = 0;
        for (i = 0; i < 7; ++i)
          for (int j = 0; j < 7; ++j)
            if (x[i] == x[j] && g[i][j]) c++;
        if (best > mx - mn || (best == mx - mn && c > bestc)) {
          best = mx - mn;
          bestc = c;
        }
      }
  printf("%d %d\n", best, bestc);
  return 0;
}
