#include <bits/stdc++.h>
using namespace std;
const int Size = 10000;
char buffer[Size];
const int inf = 0x7fffffff;
map<string, int> m;
const int size = 8;
int G[size][size];
int ar[size];
int aa, b, c;
pair<int, int> res;
void rec(int id) {
  if (id == m.size()) {
    vector<int> a[3];
    for (int i = 0; i < m.size(); i++) {
      if (ar[i] == 0)
        a[0].push_back(i);
      else if (ar[i] == 1)
        a[1].push_back(i);
      else
        a[2].push_back(i);
    }
    int s = 0;
    for (int k = 0; k < 3; k++) {
      for (int i = 0; i < ((int)a[k].size()); i++) {
        for (int j = 0; j < ((int)a[k].size()); j++) s += G[a[k][i]][a[k][j]];
      }
    }
    for (int i = 0; i < 3; i++)
      if (((int)a[i].size()) == 0) return;
    vector<int> r;
    r.push_back(aa / a[0].size());
    r.push_back(b / a[1].size());
    r.push_back(c / a[2].size());
    sort(r.begin(), r.end());
    int f = r[2] - r[0];
    res = min(res, make_pair(f, -s));
    return;
  }
  for (int i = 0; i < 3; i++) {
    ar[id] = i;
    rec(id + 1);
  }
}
int solution(int nTest) {
  int n;
  res = make_pair(inf, 0);
  m["Anka"] = 0;
  m["Chapay"] = 1;
  m["Cleo"] = 2;
  m["Troll"] = 3;
  m["Dracul"] = 4;
  m["Snowy"] = 5;
  m["Hexadecimal"] = 6;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", buffer);
    string name = buffer;
    int u = m[name];
    scanf("%s", buffer);
    scanf("%s", buffer);
    name = buffer;
    int v = m[name];
    G[u][v] = 1;
  }
  scanf("%d%d%d", &aa, &b, &c);
  rec(0);
  printf("%d %d\n", res.first, -res.second);
  return 0;
}
int main() {
  int i = 0, n = 99999;
  while (i < n && solution(i)) i++;
  return 0;
}
