#include <bits/stdc++.h>
using namespace std;
vector<vector<bool> > rel(7, vector<bool>(7, false));
vector<int> group(7);
int maxr = 0;
long long a, b, c, rmin;
void solve(int k) {
  if (k < 7) {
    for (int i = 0; i < 3; i++) {
      group[k] = i;
      solve(k + 1);
    }
  } else {
    int c1 = 0, c2 = 0, c3 = 0;
    for (int i = 0; i < 7; i++) {
      if (group[i] == 0)
        c1++;
      else if (group[i] == 1)
        c2++;
      else
        c3++;
    }
    if (c1 * c2 * c3 > 0) {
      int ratmax = max(a / c1, max(b / c2, c / c3));
      int ratmin = min(a / c1, min(b / c2, c / c3));
      int drat = ratmax - ratmin;
      int r = 0;
      for (int i = 0; i < 7; i++)
        for (int j = 0; j < 7; j++) {
          if (rel[i][j] && group[i] == group[j]) r++;
        }
      if (rmin == drat && r > maxr) maxr = r;
      if (rmin > drat) {
        rmin = drat;
        maxr = r;
      }
    }
  }
}
int main() {
  int n;
  cin >> n;
  string s1, s2, s3;
  map<string, int> he;
  he["Anka"] = 0;
  he["Chapay"] = 1;
  he["Cleo"] = 2;
  he["Troll"] = 3;
  he["Dracul"] = 4;
  he["Snowy"] = 5;
  he["Hexadecimal"] = 6;
  for (int i = 0; i < n; i++) {
    cin >> s1 >> s2 >> s3;
    rel[he[s1]][he[s3]] = true;
  }
  cin >> a >> b >> c;
  rmin = a + b + c;
  solve(0);
  cout << rmin << " " << maxr << endl;
  return 0;
}
