#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9 + 1;
map<string, int> m;
map<pair<int, int>, bool> m1;
int n;
int a, b, c;
int mn_diff = inf, mx_liking = 0;
void initialize() {
  m["Anka"] = 1;
  m["Chapay"] = 2;
  m["Cleo"] = 3;
  m["Troll"] = 4;
  m["Dracul"] = 5;
  m["Snowy"] = 6;
  m["Hexadecimal"] = 7;
}
int find_likings(vector<int> team) {
  int n1 = team.size();
  unordered_map<int, int> temp;
  for (auto &it : team) ++temp[it];
  int ans = 0;
  for (int i = 0; i < n1; ++i) {
    for (int j = 0; j < n1; ++j) {
      if (i == j) continue;
      if (m1[{team[i], team[j]}]) ++ans;
    }
  }
  return ans;
}
vector<int> team1, team2, team3;
void update_ans() {
  int exp1 = a / team1.size();
  int exp2 = b / team2.size();
  int exp3 = c / team3.size();
  int mn = min(exp1, min(exp2, exp3));
  int mx = max(exp1, max(exp2, exp3));
  int l1 = find_likings(team1);
  int l2 = find_likings(team2);
  int l3 = find_likings(team3);
  if (mx - mn < mn_diff) {
    mn_diff = mx - mn;
    mx_liking = l1 + l2 + l3;
  } else if (mx - mn == mn_diff) {
    mx_liking = max(mx_liking, l1 + l2 + l3);
  }
}
void solve(int i) {
  if (i == 8) {
    if (team1.size() > 0 && team2.size() > 0 && team3.size() > 0) {
      update_ans();
    }
    return;
  }
  team1.push_back(i);
  solve(i + 1);
  team1.pop_back();
  team2.push_back(i);
  solve(i + 1);
  team2.pop_back();
  team3.push_back(i);
  solve(i + 1);
  team3.pop_back();
}
void input() {
  initialize();
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string p, q, r;
    cin >> p >> q >> r;
    m1[{m[p], m[r]}] = true;
  }
  cin >> a >> b >> c;
  solve(1);
  cout << mn_diff << " " << mx_liking << endl;
}
int main() {
  input();
  return 0;
}
