#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
int inp[3] = {};
int maze[8][8] = {};
void p() {
  mp["Anka"] = 0;
  mp["Chapay"] = 1;
  mp["Cleo"] = 2;
  mp["Troll"] = 3;
  mp["Dracul"] = 4;
  mp["Snowy"] = 5;
  mp["Hexadecimal"] = 6;
}
int ans[2] = {2000000003, -1};
int pstk[3] = {};
int stk[3][8] = {};
void dfs(int n) {
  if (n == 7) {
    if (pstk[0] == 0 || pstk[1] == 0 || pstk[2] == 0) return;
    int asum = 0;
    int exp[3] = {};
    for (int i = 0; i < 3; ++i) {
      exp[i] = inp[i] / pstk[i];
      for (int q = 0; q < pstk[i]; ++q) {
        for (int p = 0; p < pstk[i]; ++p) {
          asum += maze[stk[i][q]][stk[i][p]];
        }
      }
    }
    sort(exp, exp + 3);
    if (exp[2] - exp[0] < ans[0]) {
      ans[0] = exp[2] - exp[0];
      ans[1] = asum;
    }
    if (exp[2] - exp[0] == ans[0]) {
      if (asum > ans[1]) ans[1] = asum;
    }
    return;
  }
  for (int i = 0; i < 3; ++i) {
    stk[i][pstk[i]] = n;
    pstk[i]++;
    dfs(n + 1);
    pstk[i]--;
  }
}
int main() {
  mp.clear();
  p();
  int n;
  for (int i = 0; i < 8; i++)
    for (int j = 0; j < 8; j++) maze[i][j] = 0;
  cin >> n;
  string s, ss, sss;
  for (int i = 0; i < n; ++i) {
    cin >> s >> ss >> sss;
    maze[mp[s]][mp[sss]] = 1;
  }
  cin >> inp[0] >> inp[1] >> inp[2];
  dfs(0);
  cout << ans[0] << " " << ans[1] << endl;
  return 0;
}
