#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using pi = pair<int, int>;
const int mod = 1e9 + 7;
const ll inf = ll(1e18);
const double PI = acos(-1), eps = 1e-9;
const int mxn = 42, mxa = 7;
int n, a, b, c;
vi adj[mxa + 5];
void solve() {
  cin >> n;
  map<string, int> m;
  int id = 0;
  while (n--) {
    string s1, second, s2;
    cin >> s1 >> second >> s2;
    if (!m.count(s1)) m[s1] = id++;
    if (!m.count(s2)) m[s2] = id++;
    adj[m[s1]].push_back(m[s2]);
  }
  cin >> a >> b >> c;
  int cur = 0x3f3f3f3f;
  vector<vi> partition;
  for (int i = 1; i <= 5; ++i) {
    for (int j = 1; j <= 6 - i; ++j) {
      int a1 = a / i, b1 = b / j, c1 = c / (7 - i - j);
      int temp = max({a1, b1, c1}) - min({a1, b1, c1});
      if (temp < cur) {
        cur = temp;
        partition.clear();
      }
      if (temp == cur) partition.push_back({i, j, 7 - i - j});
    }
  }
  int ans = 0;
  for (const vi &v : partition) {
    for (int i = 0; i < (1 << 7); ++i) {
      if (__builtin_popcount(i) != v[0]) continue;
      for (int j = 0; j < (1 << 7); ++j) {
        if (__builtin_popcount(j) != v[1] || i & j) continue;
        int cnt = 0;
        set<int> s1, s2, s3;
        for (int k = 0; k < 7; ++k) {
          if ((i >> k) & 1)
            s1.insert(k);
          else if ((j >> k) & 1)
            s2.insert(k);
          else
            s3.insert(k);
        }
        for (const int &x : s1) {
          for (const int &d : adj[x])
            if (s1.count(d)) ++cnt;
        }
        for (const int &x : s2) {
          for (const int &d : adj[x])
            if (s2.count(d)) ++cnt;
        }
        for (const int &x : s3) {
          for (const int &d : adj[x])
            if (s3.count(d)) ++cnt;
        }
        ans = max(ans, cnt);
      }
    }
  }
  cout << cur << ' ' << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  t = 1;
  while (t--) solve();
}
