#include <bits/stdc++.h>
using namespace std;
template <class T>
string i2s(T x) {
  ostringstream o;
  o << x;
  return o.str();
}
int n, a, b, c;
bool like[7][7];
vector<int> v;
pair<int, int> get(int a1, int a2, int a3) {
  int b1 = a / a1, b2 = b / a2, b3 = c / a3;
  int diff = max(max(abs(b1 - b2), abs(b1 - b3)), abs(b2 - b3));
  int lk = 0;
  for (int i = 0; i < a1; ++i) {
    for (int j = 0; j < a1; ++j) {
      if (i != j && like[v[i]][v[j]]) {
        lk++;
      }
    }
  }
  for (int i = a1; i < a1 + a2; ++i) {
    for (int j = a1; j < a1 + a2; ++j) {
      if (i != j && like[v[i]][v[j]]) {
        lk++;
      }
    }
  }
  for (int i = a1 + a2; i < 7; ++i) {
    for (int j = a1 + a2; j < 7; ++j) {
      if (i != j && like[v[i]][v[j]]) {
        lk++;
      }
    }
  }
  return make_pair(diff, lk);
}
int main() {
  map<string, int> heros;
  heros["Anka"] = 0;
  heros["Chapay"] = 1;
  heros["Cleo"] = 2;
  heros["Dracul"] = 3;
  heros["Hexadecimal"] = 4;
  heros["Snowy"] = 5;
  heros["Troll"] = 6;
  memset(like, 0, sizeof(like));
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    char s1[20], s2[20];
    scanf("%s likes %s", s1, s2);
    like[heros[s1]][heros[s2]] = true;
  }
  scanf("%d %d %d", &a, &b, &c);
  int mindiff = 2000000000, maxlike = 0;
  for (int i = 0; i < 7; ++i) v.push_back(i);
  do {
    for (int i = 1; i <= 5; ++i) {
      for (int j = 1; i + j <= 6; ++j) {
        int k = 7 - i - j;
        pair<int, int> tmp = get(i, j, k);
        if (tmp.first < mindiff ||
            (tmp.first == mindiff && tmp.second > maxlike)) {
          mindiff = tmp.first;
          maxlike = tmp.second;
        }
      }
    }
  } while (next_permutation(v.begin(), v.end()));
  printf("%d %d\n", mindiff, maxlike);
  return 0;
}
