#include <bits/stdc++.h>
using namespace std;
string names[] = {"Anka",   "Chapay", "Cleo",       "Troll",
                  "Dracul", "Snowy",  "Hexadecimal"};
int likes[7][7];
int team_likes[1 << 7], p[32];
int f(int mask) {
  int res = 0;
  for (int i = 0; i < (7); ++i)
    if (mask & p[i])
      for (int j = 0; j < (i); ++j)
        if ((mask & p[j])) res += likes[i][j];
  return res;
}
int main() {
  for (int i = 0; i < (32); ++i) p[i] = 1 << i;
  int n;
  long long a, b, c, aux[3], res, liking;
  string name1, name2, junk;
  cin >> n;
  for (int i = 0; i < (n); ++i) {
    cin >> name1 >> junk >> name2;
    int n1 = find(names, names + 7, name1) - names,
        n2 = find(names, names + 7, name2) - names;
    likes[n1][n2]++;
    likes[n2][n1]++;
  }
  cin >> a >> b >> c;
  res = numeric_limits<long long>::max();
  liking = 0;
  for (int i = (1); i <= (p[7] - 1); ++i)
    for (int j = (1); j <= (p[7] - 1); ++j)
      if ((i & j) == 0)
        for (int k = (1); k <= (p[7] - 1); ++k)
          if ((i & k) == 0 && (j & k) == 0 && (i | j | k) == p[7] - 1) {
            aux[0] = a / __builtin_popcount(i);
            aux[1] = b / __builtin_popcount(j);
            aux[2] = c / __builtin_popcount(k);
            sort(aux, aux + 3);
            if (aux[2] - aux[0] < res) {
              res = aux[2] - aux[0];
              liking = f(i) + f(j) + f(k);
            } else if (aux[2] - aux[0] == res) {
              liking = max(liking, 0LL + f(i) + f(j) + f(k));
            }
          }
  cout << res << " " << liking << endl;
  return 0;
}
