#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, c, x[3][8], m1, m2;
  m1 = 2000000000;
  int d[8][8];
  map<string, int> m;
  memset(d, 0, sizeof(d));
  string s;
  cin >> n;
  int t1, t2, k = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> s;
    if (m[s] == 0) {
      ++k;
      m[s] = k;
    }
    t1 = m[s];
    cin >> s;
    cin >> s;
    if (m[s] == 0) {
      ++k;
      m[s] = k;
    }
    t2 = m[s];
    d[t1][t2] = 1;
  }
  cin >> a >> b >> c;
  int mt1, mt2;
  for (int i = 0; i <= 2186; ++i) {
    x[0][0] = x[1][0] = x[2][0] = 0;
    int i1 = i;
    for (int j = 1; j <= 7; ++j) {
      x[i1 % 3][0]++;
      x[i1 % 3][x[i1 % 3][0]] = j;
      i1 /= 3;
    }
    if (x[0][0] > 0 && x[1][0] > 0 && x[2][0] > 0) {
      mt1 = max(abs(a / x[0][0] - b / x[1][0]), abs(a / x[0][0] - c / x[2][0]));
      mt1 = max(mt1, abs(b / x[1][0] - c / x[2][0]));
      mt2 = 0;
      for (int z = 0; z <= 2; ++z)
        for (int j = 1; j <= x[z][0]; ++j)
          for (int k = 1; k <= x[z][0]; ++k) mt2 += d[x[z][j]][x[z][k]];
      if (mt1 < m1 || mt1 == m1 && mt2 > m2) {
        m1 = mt1;
        m2 = mt2;
      }
    }
  }
  cout << m1 << ' ' << m2 << endl;
  return 0;
}
