#include <bits/stdc++.h>
using namespace std;
using std::string;
int a, b, c;
pair<int, int> ans;
int mark[8];
map<string, int> m;
multiset<pair<int, int> > mpp;
void grp(int i) {
  if (i == 8) {
    int cnt1 = 0, cnt2 = 0, cnt3 = 0;
    for (int i = 1; i <= 7; i++) {
      if (mark[i] == 1) cnt1++;
      if (mark[i] == 2) cnt2++;
      if (mark[i] == 3) cnt3++;
    }
    if (min(min(cnt1, cnt2), cnt3) == 0) return;
    int maxm = max(a / cnt1, max(b / cnt2, c / cnt3));
    int mini = min(a / cnt1, min(b / cnt2, c / cnt3));
    int l = 0;
    for (int i = 1; i <= 7; i++) {
      for (int j = 1; j <= 7; j++) {
        if (mark[i] == mark[j] && mpp.find(make_pair(i, j)) != mpp.end()) l++;
      }
    }
    pair<int, int> p = make_pair(maxm - mini, -l);
    if (p < ans) ans = p;
    return;
  }
  mark[i] = 1;
  grp(i + 1);
  mark[i] = 2;
  grp(i + 1);
  mark[i] = 3;
  grp(i + 1);
}
int main() {
  int n;
  cin >> n;
  ans = make_pair(INT_MAX, INT_MAX);
  m["Anka"] = 1;
  m["Cleo"] = 2;
  m["Troll"] = 3;
  m["Dracul"] = 4;
  m["Snowy"] = 5;
  m["Hexadecimal"] = 6;
  m["Chapay"] = 7;
  for (int i = 0; i < n; i++) {
    string s1, s, s2;
    cin >> s1 >> s >> s2;
    mpp.insert(make_pair(m[s1], m[s2]));
  }
  cin >> a >> b >> c;
  grp(1);
  cout << ans.first << " " << -ans.second << endl;
}
