#include <bits/stdc++.h>
using namespace std;
string names[7] = {"Anka",   "Chapay", "Cleo",       "Troll",
                   "Dracul", "Snowy",  "Hexadecimal"};
int getId(string s) {
  for (int i = 0; i < 7; i++)
    if (s == names[i]) return i;
  return -1;
}
int like[10][10];
int hero[10], a, b, c, best = -1;
long long mn = 1e10;
void bt(int cur) {
  if (cur == 8) {
    int num[3] = {0, 0, 0};
    for (int i = 0; i < 7; i++) num[hero[i]]++;
    if (num[0] && num[1] && num[2]) {
      long long tmp1 = min(min(a / num[0], b / num[1]), c / num[2]);
      long long tmp2 = max(max(a / num[0], b / num[1]), c / num[2]);
      long long val = tmp2 - tmp1;
      if (mn >= val) {
        int tmp = 0;
        for (int i = 0; i < 7; i++)
          for (int j = 0; j < 7; j++)
            if (like[i][j] && hero[i] == hero[j]) tmp++;
        if (mn == val)
          best = max(tmp, best);
        else
          best = tmp;
      }
      mn = min(mn, val);
    }
    return;
  }
  for (int i = 0; i < 3; i++) {
    hero[cur] = i;
    bt(cur + 1);
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    int id1 = getId(s1), id2 = getId(s3);
    like[id1][id2] = 1;
  }
  cin >> a >> b >> c;
  bt(0);
  cout << mn << " " << best << endl;
  return 0;
}
