#include <bits/stdc++.h>
using namespace std;
int ans1, ans2;
int t[4], v[4][10], T[10][10], A, B, C;
map<string, int> mymap;
const char *help[] = {"Anka",   "Chapay", "Cleo",       "Troll",
                      "Dracul", "Snowy",  "Hexadecimal"};
int countT() {
  int ret = 0;
  for (int k = 0; k < 3; k++) {
    for (int i = 0; i < t[k]; i++)
      for (int j = 0; j < t[k]; j++)
        if (T[v[k][i]][v[k][j]]) ret++;
  }
  return ret;
}
void go(int x) {
  if (x == 8) {
    if (!t[0] || !t[1] || !t[2]) return;
    int h[4];
    h[0] = A / t[0];
    h[1] = B / t[1];
    h[2] = C / t[2];
    sort(h, h + 3);
    int d = h[2] - h[0];
    int p = countT();
    if (d < ans1) {
      ans1 = d;
      ans2 = p;
    } else if (d == ans1) {
      ans2 = max(ans2, p);
    }
    return;
  }
  for (int i = 0; i < 3; i++) {
    v[i][t[i]++] = x;
    go(x + 1);
    t[i]--;
  }
  return;
}
int main() {
  char s1[30], s2[30], s3[30];
  for (int i = 0; i < 7; i++) mymap[help[i]] = i + 1;
  memset(T, 0, sizeof(T));
  int m;
  cin >> m;
  while (m--) {
    cin >> s1 >> s2 >> s3;
    int u, v;
    u = mymap[s1];
    v = mymap[s3];
    T[u][v] = 1;
  }
  cin >> A >> B >> C;
  ans1 = 2000000001;
  ans2 = 0;
  memset(t, 0, sizeof(t));
  go(1);
  cout << ans1 << " " << ans2 << endl;
  return 0;
}
