#include <bits/stdc++.h>
using namespace std;
map<string, int> heros;
int L[10][10];
int a, b, c;
int G[3][10];
int cont[3];
int r1, rl;
void go(int h) {
  int l = 0;
  if (h == 7) {
    if (cont[0] == 0 || cont[1] == 0 || cont[2] == 0) return;
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < cont[i]; j++) {
        for (int k = 0; k < cont[i]; k++) {
          if (L[G[i][j]][G[i][k]]) l++;
        }
      }
    }
    int maxi = max(max(a / cont[0], b / cont[1]), c / cont[2]);
    int mini = min(min(a / cont[0], b / cont[1]), c / cont[2]);
    int absi = maxi - mini;
    if (r1 > absi) {
      r1 = absi;
      rl = l;
    } else if (r1 == absi && rl < l) {
      rl = l;
    }
  } else
    for (int i = 0; i <= 2; i++) {
      G[i][cont[i]++] = h;
      go(h + 1);
      cont[i]--;
    }
}
int main() {
  heros["Anka"] = 0;
  heros["Chapay"] = 1;
  heros["Cleo"] = 2;
  heros["Troll"] = 3;
  heros["Dracul"] = 4;
  heros["Snowy"] = 5;
  heros["Hexadecimal"] = 6;
  string h1, h2, likes;
  memset(L, false, sizeof(L));
  int nl;
  cin >> nl;
  while (nl--) {
    cin >> h1 >> likes >> h2;
    L[heros[h1]][heros[h2]] = true;
  }
  cin >> a >> b >> c;
  r1 = 0x3f3f3f3f;
  rl = 0;
  go(0);
  printf("%d %d\n", r1, rl);
  return 0;
}
