#include <bits/stdc++.h>
using namespace std;
vector<int> vv[100];
long long arr[3];
long long m[8][8];
map<string, int> ma;
string r[] = {"Anka",   "Chapay", "Cleo",       "Troll",
              "Dracul", "Snowy",  "Hexadecimal"};
int main() {
  long long n;
  cin >> n;
  vector<string> v;
  long long idx = 0;
  for (long long i = 0; i < 7; i++) ma[r[i]] = i;
  for (long long i = 0; i < n; i++) {
    string s, second, sss;
    cin >> s >> second >> sss;
    m[ma[s]][ma[sss]] = 1;
  }
  long long mm = 1e10;
  for (long long i = 0; i < 3; i++) cin >> arr[i];
  vector<int> diff[100];
  for (long long i = 1; i <= 7; i++) {
    for (long long j = 1; j <= 7; j++) {
      if (i + j >= 7) break;
      long long k = 7 - (i + j);
      vector<int> q;
      q.push_back(arr[0] / i);
      q.push_back(arr[1] / j);
      q.push_back(arr[2] / k);
      sort(q.begin(), q.end());
      if (mm > q[2] - q[0]) {
        mm = q[2] - q[0];
      }
    }
  }
  cout << mm;
  int g = 0;
  for (long long i = 1; i <= 7; i++) {
    for (long long j = 1; j <= 7; j++) {
      if (i + j >= 7) break;
      long long k = 7 - (i + j);
      vector<int> q;
      q.push_back(arr[0] / i);
      q.push_back(arr[1] / j);
      q.push_back(arr[2] / k);
      sort(q.begin(), q.end());
      if (mm == q[2] - q[0]) {
        diff[g].push_back(i);
        diff[g].push_back(j);
        diff[g++].push_back(k);
      }
    }
  }
  long long ans = 0;
  for (long long z = 0; z < g; z++) {
    vector<int> c;
    for (long long i = 0; i < 7; i++) c.push_back(i);
    do {
      long long k = 0;
      for (long long i = 0; i < diff[z][0]; i++) {
        for (long long j = i + 1; j < diff[z][0]; j++) {
          k += (m[c[i]][c[j]] + m[c[j]][c[i]]);
        }
      }
      for (long long i = diff[z][0]; i < diff[z][0] + diff[z][1]; i++) {
        for (long long j = i + 1; j < diff[z][0] + diff[z][1]; j++) {
          k += (m[c[i]][c[j]] + m[c[j]][c[i]]);
        }
      }
      for (long long i = diff[z][0] + diff[z][1];
           i < diff[z][0] + diff[z][1] + diff[z][2]; i++) {
        for (long long j = i + 1; j < diff[z][0] + diff[z][1] + diff[z][2];
             j++) {
          k += (m[c[i]][c[j]] + m[c[j]][c[i]]);
        }
      }
      ans = max(ans, k);
    } while (next_permutation(c.begin(), c.end()));
  }
  cout << " " << ans;
  return 0;
}
