#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
map<string, int> x;
int likes[10][10];
int best_diff, best_liking;
int e1, e2, e3;
int assignment[8];
int find_likes() {
  int ret = 0;
  for (int i = 1; i <= 7; i++)
    for (int j = 1; j <= 7; j++)
      if (i != j)
        if (likes[i][j])
          if (assignment[i] == assignment[j]) ret++;
  return ret;
}
int assign(int hero, int b1, int b2, int b3) {
  if (hero == 8) {
    if (!(b1 * b2 * b3)) return 0;
    assert(b1 + b2 + b3 == 7);
    vector<int> exp({e1 / b1, e2 / b2, e3 / b3});
    sort(exp.begin(), exp.end());
    int exp_diff = exp[2] - exp[0];
    int nlikes = find_likes();
    if (exp_diff < best_diff)
      best_liking = nlikes, best_diff = exp_diff;
    else if (exp_diff == best_diff)
      best_liking = max(best_liking, nlikes);
    return 0;
  }
  assignment[hero] = 1;
  assign(hero + 1, b1 + 1, b2, b3);
  assignment[hero] = 2;
  assign(hero + 1, b1, b2 + 1, b3);
  assignment[hero] = 3;
  assign(hero + 1, b1, b2, b3 + 1);
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  x["Anka"] = 1;
  x["Chapay"] = 2;
  x["Cleo"] = 3;
  x["Troll"] = 4;
  x["Dracul"] = 5;
  x["Snowy"] = 6;
  x["Hexadecimal"] = 7;
  int n;
  cin >> n;
  best_diff = (int)2e9;
  for (int i = 0; i < n; i++) {
    string a, b, c;
    cin >> a >> b >> c;
    likes[x[a]][x[c]] = 1;
  }
  cin >> e1 >> e2 >> e3;
  assign(1, 0, 0, 0);
  cout << best_diff << " " << best_liking << '\n';
  return 0;
}
