#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
map<string, long long> g;
long long liking[7][7];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  g["Anka"] = 0;
  g["Chapay"] = 1;
  g["Cleo"] = 2;
  g["Troll"] = 3;
  g["Dracul"] = 4;
  g["Snowy"] = 5;
  g["Hexadecimal"] = 6;
  memset(liking, 0, sizeof(liking));
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    string a, b, c;
    cin >> a >> b >> c;
    liking[g[a]][g[c]] = 1;
  }
  vector<long long> demon(3);
  cin >> demon[0] >> demon[1] >> demon[2];
  long long ar[7] = {0};
  long long mlike = 0;
  long long ma = 1e17;
  for (long long i = 0; i < pow(3, 7); i++) {
    long long carry = 1;
    for (long long j = 0; j < 7; j++) {
      ar[j] += carry;
      carry = ar[j] / 3;
      ar[j] = ar[j] % 3;
    }
    vector<long long> groups[3];
    for (long long j = 0; j < 7; j++) {
      groups[ar[j]].push_back(j);
    }
    if (groups[0].size() == 0 || groups[1].size() == 0 || groups[2].size() == 0)
      continue;
    long long mx = 0, mn = 1e17;
    for (long long j = 0; j < 3; j++) {
      long long p = demon[j] / groups[j].size();
      mx = max(p, mx);
      mn = min(p, mn);
    }
    long long dif = mx - mn;
    long long flag = 0;
    if (dif <= ma) {
      long long cnt = 0;
      for (long long j = 0; j < 3; j++) {
        for (long long k = 0; k < groups[j].size(); k++) {
          for (long long l = 0; l < groups[j].size(); l++) {
            if (liking[groups[j][k]][groups[j][l]] == 1) {
              cnt++;
            }
          }
        }
      }
      if (ma == dif)
        mlike = max(mlike, cnt);
      else
        mlike = cnt;
      ma = dif;
    }
  }
  cout << ma << " " << mlike << "\n";
  return 0;
}
