#include <bits/stdc++.h>
using namespace std;
pair<int, int> ans;
int e[7][7], c[7], w[3];
void gao(int n) {
  if (n == 7) {
    int s[3] = {};
    for (int i = 0; i < 7; i++) s[c[i]]++;
    sort(s, s + 3);
    if (!s[0]) return;
    for (int i = 0; i < 3; i++) s[i] = w[i] / s[i];
    int cnt = 0;
    for (int i = 0; i < 7; i++)
      for (int j = 0; j < 7; j++)
        if (c[i] == c[j]) cnt -= e[i][j];
    ans = min(ans, pair<int, int>(
                       *max_element(s, s + 3) - *min_element(s, s + 3), cnt));
    return;
  }
  c[n] = 0;
  gao(n + 1);
  c[n] = 1;
  gao(n + 1);
  c[n] = 2;
  gao(n + 1);
}
int main() {
  int n;
  map<string, int> u = {{"Anka", 0},       {"Chapay", 1}, {"Cleo", 2},
                        {"Troll", 3},      {"Dracul", 4}, {"Snowy", 5},
                        {"Hexadecimal", 6}};
  scanf("%d", &n);
  char a[1000], b[1000];
  for (int i = 0; i < n; i++) {
    scanf("%s%*s%s", a, b);
    e[u[a]][u[b]] = 1;
  }
  for (int i = 0; i < 3; i++) scanf("%d", &w[i]);
  sort(w, w + 3);
  ans = {0x7FFFFFFF, 0};
  gao(0);
  printf("%d %d\n", ans.first, -ans.second);
}
