#include <bits/stdc++.h>
using namespace std;
set<string> S;
int ra = 10e8, rb;
vector<string> t[4];
string st[7] = {"Anka",   "Chapay", "Cleo",       "Troll",
                "Dracul", "Snowy",  "Hexadecimal"};
int a, b, c;
void dfs(int x) {
  if (x == 7) {
    if (!t[1].size() || !t[2].size() || !t[3].size()) return;
    int x = a / t[1].size(), y = b / t[2].size(), z = c / t[3].size();
    int d = max(x, max(y, z)) - min(x, min(y, z));
    int mx = 0;
    for (int i = 1; i <= 3; i++) {
      for (int j = 0; j < t[i].size(); j++) {
        for (int k = 0; k < t[i].size(); k++) {
          if (S.count(t[i][j] + " " + t[i][k])) mx++;
        }
      }
    }
    if (d < ra || (d == ra && mx > rb)) {
      ra = d;
      rb = mx;
    }
    return;
  }
  for (int i = 1; i <= 3; i++) {
    t[i].push_back(st[x]);
    dfs(x + 1);
    t[i].pop_back();
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string a, b, c;
    cin >> a >> b >> c;
    S.insert(a + " " + c);
  }
  cin >> a >> b >> c;
  dfs(0);
  cout << ra << " " << rb;
  return 0;
}
