#include <bits/stdc++.h>
using namespace std;
map<string, long long> m;
pair<long long, long long> par[43];
vector<string> combi;
vector<string> posi;
long long S[4];
long long A[10];
bool vis[10];
bool vi[10][10];
long long nu;
void combina(long long n) {
  if (n == 7) {
    string k;
    for (long long i = 0; i < 7; i++) {
      k = k + char(A[i] + '0');
    }
    combi.push_back(k);
    return;
  }
  for (long long i = 1; i < 8; i++) {
    if (!vis[i]) {
      vis[i] = true;
      A[n] = i;
      combina(n + 1);
      vis[i] = false;
    }
  }
  return;
}
void llena(long long n) {
  if (n == 3) {
    string k;
    long long sum = 0;
    for (long long i = 0; i < 3; i++) {
      k = k + char(S[i] + '0');
      sum = sum + S[i];
    }
    if (sum == 7) {
      posi.push_back(k);
    }
    return;
  }
  for (long long i = 1; i < 6; i++) {
    S[n] = i;
    llena(n + 1);
  }
  return;
}
long long grupo(long long ini, long long fin, string k) {
  if (fin - ini == 1) {
    return 0;
  }
  long long cnt = 0;
  for (long long i = ini; i < fin; i++) {
    for (long long j = ini; j < fin; j++) {
      if (vi[k[i] - '0'][k[j] - '0']) {
        cnt++;
      }
    }
  }
  return cnt;
}
int main() {
  llena(0);
  combina(0);
  m["Anka"] = 1;
  m["Chapay"] = 2;
  m["Cleo"] = 3;
  m["Troll"] = 4;
  m["Dracul"] = 5;
  m["Snowy"] = 6;
  m["Hexadecimal"] = 7;
  cin >> nu;
  string k;
  getline(cin, k);
  for (long long i = 0; i < nu; i++) {
    getline(cin, k);
    long long p = 0;
    string per1;
    while (k[p] != ' ' && p < k.size()) {
      per1 = per1 + k[p];
      p++;
    }
    p = p + 7;
    string per2;
    while (k[p] != ' ' && p < k.size()) {
      per2 = per2 + k[p];
      p++;
    }
    p = p + 7;
    par[i] = make_pair(m[per1], m[per2]);
    vi[m[per1]][m[per2]] = true;
  }
  long long a, b, c;
  cin >> a >> b >> c;
  vector<string> minimos;
  long long mnn = 10000000000000;
  long long mxx = 0;
  for (long long i = 0; i < posi.size(); i++) {
    long long mx = max(a / (posi[i][0] - '0'),
                       max(b / (posi[i][1] - '0'), c / (posi[i][2] - '0')));
    long long mn = min(a / (posi[i][0] - '0'),
                       min(b / (posi[i][1] - '0'), c / (posi[i][2] - '0')));
    if (mx - mn < mnn) {
      mnn = mx - mn;
      minimos.clear();
      minimos.push_back(posi[i]);
      continue;
    }
    if (mx - mn == mnn) {
      minimos.push_back(posi[i]);
      continue;
    }
  }
  long long mx = 0;
  for (long long i = 0; i < minimos.size(); i++) {
    long long a = minimos[i][0] - '0';
    long long b = minimos[i][1] - '0';
    long long c = minimos[i][2] - '0';
    for (long long j = 0; j < combi.size(); j++) {
      long long xx = grupo(0, a, combi[j]);
      long long yy = grupo(a, a + b, combi[j]);
      long long zz = grupo(a + b, a + b + c, combi[j]);
      mx = max(mx, xx + yy + zz);
    }
  }
  cout << mnn << " " << mx << endl;
  return 0;
}
