#include <bits/stdc++.h>
using namespace std;
map<string, int> idx;
vector<int> team[3];
int e[3], mn = INT_MAX, mx = INT_MIN;
bool v[7][7];
void init() {
  idx["Anka"] = 0;
  idx["Chapay"] = 1;
  idx["Cleo"] = 2;
  idx["Troll"] = 3;
  idx["Dracul"] = 4;
  idx["Snowy"] = 5;
  idx["Hexadecimal"] = 6;
}
void dfs(int d) {
  if (d == 7) {
    if (team[0].empty() || team[1].empty() || team[2].empty()) return;
    int emn = INT_MAX, emx = INT_MIN;
    for (int i = 0; i < 3; ++i) {
      emn = min(emn, e[i] / (int)team[i].size());
      emx = max(emx, e[i] / (int)team[i].size());
    }
    int liking = 0;
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < (int)team[i].size(); ++j) {
        for (int k = 0; k < (int)team[i].size(); ++k) {
          liking += v[team[i][j]][team[i][k]];
        }
      }
    }
    emx -= emn;
    if (emx < mn)
      mn = emx, mx = liking;
    else if (emx == mn && liking > mx)
      mx = liking;
    return;
  }
  for (int i = 0; i < 3; ++i) {
    team[i].push_back(d);
    dfs(d + 1);
    team[i].pop_back();
  }
}
int main() {
  init();
  int n;
  string p, q, like;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> p >> like >> q;
    v[idx[p]][idx[q]] = true;
  }
  cin >> e[0] >> e[1] >> e[2];
  dfs(0);
  cout << mn << " " << mx;
  return 0;
}
