#include <bits/stdc++.h>
using namespace std;
int hero_id(const std::string &name) {
  if (name == "Anka") return 0;
  if (name == "Chapay") return 1;
  if (name == "Cleo") return 2;
  if (name == "Troll") return 3;
  if (name == "Dracul") return 4;
  if (name == "Snowy") return 5;
  if (name == "Hexadecimal") return 6;
  assert(0);
  return -1;
}
int main() {
  int N;
  cin >> N;
  vector<vector<char> > likes(7, vector<char>(7, 0));
  for (int n = 0; n < int(N); ++n) {
    string a, x, b;
    cin >> a >> x >> b;
    assert(x == "likes");
    likes[hero_id(a)][hero_id(b)] = 1;
  }
  int A, B, C;
  cin >> A >> B >> C;
  int best_diff = 2123456789;
  int best_likings = -1;
  vector<int> team(7, 0);
  do {
    bool carry = 1;
    for (__typeof((team).begin()) it = (team).begin(); it != (team).end();
         ++it) {
      *it += carry;
      if (*it == 3) {
        *it = 0;
        carry = 1;
      } else {
        carry = 0;
      }
    }
    int cnt[3] = {0, 0, 0};
    for (__typeof((team).begin()) it = (team).begin(); it != (team).end(); ++it)
      ++cnt[*it];
    if (!cnt[0] || !cnt[1] || !cnt[2]) continue;
    int exp[3] = {A / cnt[0], B / cnt[1], C / cnt[2]};
    int diff =
        max(max(exp[0], exp[1]), exp[2]) - min(min(exp[0], exp[1]), exp[2]);
    int likings = 0;
    for (int i = 0; i < int(7); ++i)
      for (int j = 0; j < int(7); ++j)
        if (likes[i][j] && team[i] == team[j]) ++likings;
    if (diff < best_diff || (diff == best_diff && likings > best_likings)) {
      best_diff = diff;
      best_likings = likings;
    }
  } while (team != vector<int>(7, 0));
  cout << best_diff << ' ' << best_likings << endl;
}
