#include <bits/stdc++.h>
using namespace std;
int gra[10][10];
int a, b, c, n;
map<string, int> mp;
int id[10];
int ans1, ans2;
void dfs(int s) {
  if (s >= 8) {
    int na = 0, nb = 0, nc = 0;
    for (int i = 1; i <= 7; i++)
      if (id[i] == 0)
        na++;
      else if (id[i] == 1)
        nb++;
      else
        nc++;
    if (!na || !nb || !nc) return;
    int num = 0;
    for (int i = 1; i <= 7; i++)
      for (int j = 1; j <= 7; j++)
        if (gra[i][j] && id[i] == id[j]) num++;
    int maxx, minn;
    maxx = max(a / na, max(b / nb, c / nc));
    minn = min(a / na, min(b / nb, c / nc));
    if (maxx - minn < ans1 || (maxx - minn == ans1 && num > ans2)) {
      ans1 = maxx - minn;
      ans2 = num;
    }
    return;
  }
  for (int i = 0; i < 3; i++) {
    id[s] = i;
    dfs(s + 1);
  }
}
int main() {
  mp.clear();
  mp["Anka"] = 1;
  mp["Chapay"] = 2;
  mp["Cleo"] = 3;
  mp["Troll"] = 4;
  mp["Dracul"] = 5;
  mp["Snowy"] = 6;
  mp["Hexadecimal"] = 7;
  cin >> n;
  memset(gra, 0, sizeof(gra));
  for (int i = 0; i < n; i++) {
    string aa, bb, cc;
    cin >> aa >> bb >> cc;
    gra[mp[aa]][mp[cc]] = 1;
  }
  cin >> a >> b >> c;
  ans1 = 0x3f3f3f3f;
  dfs(1);
  cout << ans1 << " " << ans2 << endl;
}
