#include <bits/stdc++.h>
using namespace std;
int g[10][10];
int PA[10];
int m, a, b, c, ans1, ans2;
string s1, s2, s3;
map<string, int> mm;
int aa(int x) { return x < 0 ? -x : x; }
void rec(int i, int c1, int c2, int c3) {
  if (i == 7) {
    if (c1 == 0 || c2 == 0 || c3 == 0) return;
    int ac = a / c1;
    int bc = b / c2;
    int cc = c / c3;
    int mn = min(ac, min(bc, cc));
    int mx = max(ac, max(bc, cc));
    int r1 = mx - mn;
    int r2 = 0;
    for (int i = 0; i < (int)(7); i++)
      for (int j = 0; j < (int)(7); j++)
        if (g[i][j] && PA[i] == PA[j]) r2++;
    if (ans1 == -1 || (r1 < ans1 || (r1 == ans1 && r2 > ans2))) {
      ans1 = r1;
      ans2 = r2;
    }
    return;
  }
  PA[i] = 0;
  rec(i + 1, c1 + 1, c2, c3);
  PA[i] = 1;
  rec(i + 1, c1, c2 + 1, c3);
  PA[i] = 2;
  rec(i + 1, c1, c2, c3 + 1);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  mm["Anka"] = 0, mm["Chapay"] = 1, mm["Cleo"] = 2, mm["Troll"] = 3,
  mm["Dracul"] = 4, mm["Snowy"] = 5, mm["Hexadecimal"] = 6;
  cin >> m;
  for (int i = 0; i < (int)(m); i++) {
    cin >> s1 >> s2 >> s3;
    g[mm[s1]][mm[s3]] = 1;
  }
  cin >> a >> b >> c;
  ans1 = ans2 = -1;
  rec(0, 0, 0, 0);
  cout << ans1 << " " << ans2 << endl;
  return 0;
}
