#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-9;
vector<string> S;
int A[7][7];
int main(void) {
  int n, j;
  string s1, s2, s3;
  vector<int> e(3);
  cin >> n;
  for (int i = 0; i < (int)(n); i++) {
    int i1, i2;
    cin >> s1 >> s2 >> s3;
    for (j = 0; j < (int)S.size(); j++) {
      if (S[j] == s1) break;
    }
    if (j == (int)S.size()) S.push_back(s1);
    i1 = j;
    for (j = 0; j < (int)S.size(); j++) {
      if (S[j] == s3) break;
    }
    if (j == (int)S.size()) S.push_back(s3);
    i2 = j;
    A[i1][i2] = 1;
  }
  cin >> e[0] >> e[1] >> e[2];
  sort(e.begin(), e.end());
  int max_liking = -1;
  int min_diff = INT_MAX;
  for (int i = 0; i < (1 << (2 * 7)); i++) {
    int c[4];
    int b[7];
    int sc = 0;
    c[0] = c[1] = c[2] = c[3] = 0;
    int tmp = i;
    for (j = 0; j < 7; j++) {
      c[tmp & 3]++;
      b[j] = tmp & 3;
      tmp >>= 2;
    }
    if (c[0] == 0 || c[1] == 0 || c[2] == 0 || c[3] != 0) continue;
    for (j = 0; j < 7; j++) {
      for (int k = 0; k < 7; k++) {
        if (j == k) continue;
        if (A[j][k] == 1 && b[j] == b[k]) sc++;
      }
    }
    sort(&c[0], &c[3]);
    c[0] = e[0] / c[0];
    c[1] = e[1] / c[1];
    c[2] = e[2] / c[2];
    sort(&c[0], &c[3]);
    int tmp_min_diff = c[2] - c[0];
    if (tmp_min_diff < min_diff) {
      min_diff = tmp_min_diff;
      max_liking = sc;
    } else if (tmp_min_diff == min_diff) {
      if (max_liking < sc) max_liking = sc;
    }
  }
  cout << min_diff << " " << max_liking << endl;
  return 0;
}
