#include <bits/stdc++.h>
using namespace std;
map<string, int> MP;
int M(string s) {
  if (MP.find(s) == MP.end()) {
    int sz = MP.size();
    MP[s] = sz;
    return sz;
  }
  return MP[s];
}
int g[7][7] = {0};
char s[100], t[100];
int a[3];
int main() {
  int n;
  scanf("%d", &n);
  while (n--) {
    scanf("%s%*s%s", s, t);
    int first = M(s), second = M(t);
    g[first][second] = 1;
  }
  for (int i = (0); i < (int)(3); i++) scanf("%d", a + i);
  long long diff = 1LL << 60;
  int like = -1;
  for (int z = (0); z < (int)(2187); z++) {
    int arr[7], cnt[3] = {0};
    for (int first = z, i = 0; i < 7; first /= 3, i++) {
      arr[i] = first % 3;
      cnt[first % 3]++;
    }
    long long mx = -(1LL << 60), mn = 1LL << 60;
    for (int i = (0); i < (int)(7); i++) {
      long long t = a[arr[i]] / cnt[arr[i]];
      mx = max(mx, t);
      mn = min(mn, t);
    }
    bool ok = 1;
    for (int i = (0); i < (int)(3); i++) ok &= cnt[i] > 0;
    if (!ok) continue;
    int lk = 0;
    for (int i = (0); i < (int)(7); i++)
      for (int j = (0); j < (int)(7); j++) {
        if (g[i][j] && arr[i] == arr[j]) {
          ++lk;
        }
      }
    long long d = mx - mn;
    if (d < diff || (d == diff && lk > like)) {
      diff = d;
      like = lk;
    }
  }
  printf("%d %d\n", (int)diff, like);
  return 0;
}
