#include <bits/stdc++.h>
using namespace std;
const int N = 2e2 + 5;
int n, num = 0, l[N][N], a[N], b[N], res = 2e9, like = 0;
string s1, s2, s3;
map<string, int> mp = {{"Anka", 1},       {"Chapay", 2}, {"Cleo", 3},
                       {"Troll", 4},      {"Dracul", 5}, {"Snowy", 6},
                       {"Hexadecimal", 7}};
void calc() {
  int c[N] = {0};
  for (int i = 1; i <= num; i++) c[b[i]]++;
  for (int i = 1; i <= 3; i++)
    if (c[i] == 0) return;
  int mx = 0, mn = 2e9;
  for (int i = 1; i <= 3; i++) {
    int exe = ceil(a[i] / c[i]);
    mx = max(mx, exe);
    mn = min(mn, exe);
  }
  if (mx - mn <= res) {
    int t = 0;
    for (int i = 1; i <= num; i++)
      for (int j = 1; j <= num; j++)
        if (i != j && b[i] == b[j] && l[i][j] == true) t++;
    if (res == mx - mn)
      like = max(like, t);
    else
      res = mx - mn, like = t;
  }
}
void dfs(int cur) {
  if (cur == num + 1) {
    calc();
    return;
  }
  for (int i = 1; i <= 3; i++) {
    b[cur] = i;
    dfs(cur + 1);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s1 >> s2 >> s3;
    int x = mp[s1], y = mp[s3];
    l[x][y] = true;
  }
  num = 7;
  for (int i = 1; i <= 3; i++) cin >> a[i];
  dfs(1);
  cout << res << ' ' << like << '\n';
  return 0;
}
