#include <bits/stdc++.h>
using namespace std;
struct Conf {
  int n1, n2, n3;
  Conf() { n1 = n2 = n3 = 0; }
  Conf(int a, int b, int c) { n1 = a, n2 = b, n3 = c; };
};
int likeGraph[8][8];
map<string, int> heroes;
int n;
int a, b, c;
int p[8];
vector<Conf> possConf;
int minDiff;
int maxLike;
int countLike(int from, int to) {
  int res = 0;
  for (int i = from; i <= to; i++)
    for (int j = from; j <= to; j++)
      if (i != j) {
        if (likeGraph[p[i]][p[j]] == 1) res++;
      }
  return res;
};
int main() {
  heroes["Anka"] = 0;
  heroes["Chapay"] = 1;
  heroes["Cleo"] = 2;
  heroes["Troll"] = 3;
  heroes["Dracul"] = 4;
  heroes["Snowy"] = 5;
  heroes["Hexadecimal"] = 6;
  memset(likeGraph, 0, sizeof likeGraph);
  cin >> n;
  for (int i = 0; i < n; i++) {
    string a, b, c;
    cin >> a >> b >> c;
    likeGraph[heroes[a]][heroes[c]] = 1;
  }
  cin >> a >> b >> c;
  minDiff = 2100000000;
  for (int i = 1; i <= 7; i++)
    for (int j = 1; j <= 7; j++) {
      int k = 7 - i - j;
      if (k <= 0) continue;
      int maxEarn = max(a / i, max(b / j, c / k));
      int minEarn = min(a / i, min(b / j, c / k));
      if (maxEarn - minEarn < minDiff) {
        minDiff = maxEarn - minEarn;
        possConf.clear();
        possConf.push_back(Conf(i, j, k));
      } else if (maxEarn - minEarn == minDiff) {
        possConf.push_back(Conf(i, j, k));
      }
    }
  maxLike = 0;
  for (int i = 0; i < 7; i++) p[i] = i;
  do {
    for (unsigned i = 0; i < possConf.size(); i++) {
      int n1 = possConf[i].n1, n2 = possConf[i].n2, n3 = possConf[i].n3;
      int totalLike = countLike(0, n1 - 1) + countLike(n1, n1 + n2 - 1) +
                      countLike(n1 + n2, 6);
      maxLike = max(totalLike, maxLike);
    }
  } while (next_permutation(p, p + 7));
  cout << minDiff << " " << maxLike << endl;
  return 0;
}
