#include <bits/stdc++.h>
using namespace std;
const char *names[] = {"Anka",   "Chapay", "Cleo",       "Troll",
                       "Dracul", "Snowy",  "Hexadecimal"};
bool g[7][7];
int id(char *name) {
  for (int i = 0; i < 7; i++)
    if (!strcmp(name, names[i])) return i;
  return -1;
}
int main() {
  int n;
  scanf("%d", &n);
  memset(g, 0, sizeof(g));
  for (int i = 0; i < n; i++) {
    char name1[1024], name2[1024], temp[1024];
    scanf("%s%s%s", name1, temp, name2);
    g[id(name1)][id(name2)] = true;
  }
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  int diff = INT_MAX;
  int liking = INT_MIN;
  for (int i = 0; i < (1 << 14); i++) {
    int sel[7];
    int z[3] = {};
    bool valid = true;
    for (int j = 0; j < 7; j++) {
      sel[j] = (i >> j * 2) & 3;
      if (sel[j] == 3) {
        valid = false;
        break;
      }
      z[sel[j]]++;
    }
    if (!valid) continue;
    if (z[0] == 0 || z[1] == 0 || z[2] == 0) continue;
    z[0] = a / z[0];
    z[1] = b / z[1];
    z[2] = c / z[2];
    sort(z, z + 3);
    if (diff < z[2] - z[0]) continue;
    int count = 0;
    for (int y = 0; y < 7; y++)
      for (int x = 0; x < 7; x++) {
        if (sel[y] != sel[x]) continue;
        if (g[y][x]) count++;
      }
    if (diff > z[2] - z[0] || (diff == z[2] - z[0] && liking < count)) {
      diff = z[2] - z[0];
      liking = count;
    }
  }
  printf("%d %d\n", diff, liking);
  return 0;
}
