#include <bits/stdc++.h>
using namespace std;
class like {
 public:
  string ff;
  string ss;
  bool operator<(const like &other) const {
    return make_pair(ff, ss) < make_pair(other.ff, other.ss);
  }
};
map<like, int> sp;
string name[7] = {"Anka",   "Chapay", "Cleo",       "Troll",
                  "Dracul", "Snowy",  "Hexadecimal"};
int ud(int arr[8], int t) {
  int sum = 0;
  for (int u = 0; u < t - 1; u++)
    for (int w = u + 1; w < t; w++) {
      like tm;
      tm.ff = name[arr[u]];
      tm.ss = name[arr[w]];
      sum += sp[tm];
      tm.ff = name[arr[w]];
      tm.ss = name[arr[u]];
      sum += sp[tm];
    }
  return sum;
}
int main() {
  int n, a, b, c, j, m = 2000000005, likemax = -1;
  int sos[7] = {};
  scanf("%d\n", &n);
  char f[50] = {}, s[50] = {};
  for (int i = 0; i < n; i++) {
    scanf("%s likes %s", f, s);
    like tmp;
    tmp.ff = f;
    tmp.ss = s;
    sp[tmp] = 1;
  }
  scanf("%d %d %d", &a, &b, &c);
  for (int i = 1; i <= 5; i++) {
    for (int k = 1; k <= 6 - i; k++) {
      j = 7 - i - k;
      int ma = max(max(a / i, b / k), c / j);
      int mi = min(min(a / i, b / k), c / j);
      if (ma - mi < m) m = ma - mi;
    }
  }
  for (int i = 1; i <= 5; i++) {
    for (int k = 1; k <= 6 - i; k++) {
      j = 7 - i - k;
      int ma = max(max(a / i, b / k), c / j);
      int mi = min(min(a / i, b / k), c / j);
      if (ma - mi == m) {
        for (int w = 0; w < 7; w++) {
          if (w < i) {
            sos[w] = 1;
            continue;
          };
          if (w < i + k) {
            sos[w] = 2;
            continue;
          };
          if (w < 7) {
            sos[w] = 3;
            continue;
          };
        }
        do {
          int ll = 0, ii = 0, kk = 0, jj = 0;
          int mas[3][8] = {};
          for (int w = 0; w < 7; w++) {
            if (sos[w] == 1) {
              mas[0][ii] = w;
              ii++;
            }
            if (sos[w] == 2) {
              mas[1][kk] = w;
              kk++;
            }
            if (sos[w] == 3) {
              mas[2][jj] = w;
              jj++;
            }
          }
          ll = ud(mas[0], i) + ud(mas[1], k) + ud(mas[2], j);
          if (ll > likemax) likemax = ll;
        } while (next_permutation(sos, sos + 7));
      }
    }
  }
  cout << m << ' ' << likemax;
  return 0;
}
