#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const long long N = 3e5 + 7;
long long n, a, b, c;
long long arr[N], mat[8][8];
map<string, long long> val;
pair<long long, long long> getans(long long n, string str) {
  if (n == 0) {
    map<long long, long long> val;
    long long t[3] = {0};
    for (long long i = 0; i < 7; i++) {
      val[i] = str[i] - '0';
      t[val[i]]++;
    }
    if (t[0] * t[1] * t[2] == 0) return {1e18, -1};
    long long mx = max(a / t[0], max(b / t[1], c / t[2]));
    long long mn = min(a / t[0], min(b / t[1], c / t[2]));
    long long a1 = mx - mn, likes = 0;
    for (long long h = 0; h < 7; h++) {
      for (long long m = 0; m < 7; m++) {
        if (mat[h][m] == 1 and val[h] == val[m]) likes++;
      }
    }
    return {a1, likes};
  }
  pair<long long, long long> ans = {1e18, -1};
  for (long long i = 0; i < 3; i++) {
    char ch = '0' + i;
    pair<long long, long long> a = getans(n - 1, str + ch);
    if (a.first < ans.first)
      ans = a;
    else if (a.first == ans.first and a.second > ans.second)
      ans = a;
  }
  return ans;
}
void solve() {
  cin >> n;
  string a1, likes, b1;
  for (long long i = 0; i < n; i++) {
    cin >> a1 >> likes >> b1;
    mat[val[a1]][val[b1]] = 1;
  }
  cin >> a >> b >> c;
  pair<long long, long long> res = getans(7, "");
  cout << res.first << " " << res.second;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long cnt = 0;
  string str = "Anka Chapay Cleo Troll Dracul Snowy Hexadecimal";
  stringstream g(str);
  string name;
  while (g >> name) {
    val[name] = cnt++;
  }
  long long t = 1;
  while (t--) solve();
}
