#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int f(string s) {
  if (s == "Anka")
    return 0;
  else if (s == "Chapay")
    return 1;
  else if (s == "Cleo")
    return 2;
  else if (s == "Troll")
    return 3;
  else if (s == "Dracul")
    return 4;
  else if (s == "Snowy")
    return 5;
  else if (s == "Hexadecimal")
    return 6;
  else
    return -1;
}
int main() {
  vector<int> un(7);
  for (int i = 0; i < int((un).size()); i++) un[i] = i;
  vector<vector<int> > like(7);
  for (int i = 0; i < int((like).size()); i++) like[i].resize(7);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s1, h, s2;
    cin >> s1 >> h >> s2;
    like[f(s1)][f(s2)] = 1;
  }
  vector<int> bonus(3);
  for (int i = 0; i < int((bonus).size()); i++) cin >> bonus[i];
  vector<int> h(7);
  int ans1 = 2000000001, ans2 = 2000000001;
  do {
    for (int i = 0; i <= 4; ++i)
      for (int j = i + 1; j <= 5; ++j) {
        int n1 = i + 1, n2 = j - i, n3 = 7 - n1 - n2;
        for (int t = 0; t <= i; ++t) h[t] = bonus[0] / n1;
        for (int t = i + 1; t <= j; ++t) h[t] = bonus[1] / n2;
        for (int t = j + 1; t <= 6; ++t) h[t] = bonus[2] / n3;
        int curmn =
            *max_element(h.begin(), h.end()) - *min_element(h.begin(), h.end());
        int curans2 = 0;
        if (n1 > 1)
          for (int t1 = 0; t1 <= i - 1; ++t1)
            for (int t2 = t1 + 1; t2 <= i; ++t2) {
              curans2 += like[un[t1]][un[t2]];
              curans2 += like[un[t2]][un[t1]];
            }
        if (n2 > 1)
          for (int t1 = i + 1; t1 <= j - 1; ++t1)
            for (int t2 = t1 + 1; t2 <= j; ++t2) {
              curans2 += like[un[t1]][un[t2]];
              curans2 += like[un[t2]][un[t1]];
            }
        if (n3 > 1)
          for (int t1 = j + 1; t1 <= 5; ++t1)
            for (int t2 = t1 + 1; t2 <= 6; ++t2) {
              curans2 += like[un[t1]][un[t2]];
              curans2 += like[un[t2]][un[t1]];
            }
        if (curmn < ans1 || curmn == ans1 && curans2 > ans2) {
          ans1 = curmn;
          ans2 = curans2;
        }
      }
  } while (next_permutation(un.begin(), un.end()));
  cout << ans1 << ' ' << ans2 << endl;
  return 0;
}
