#include <bits/stdc++.h>
using namespace std;
int a, b, c, num, res = 2000000000, symp, mx, mn;
int ng[3], group[7], likes[7][7];
map<string, int> heroes;
int o[3] = {0, 1, 2};
int getNum(string s) {
  if (!heroes.count(s)) heroes[s] = num++;
  return heroes[s];
}
void go(int lev) {
  if (lev == 7) {
    if (ng[0] && ng[1] && ng[2]) {
      int d = 2000000000;
      vector<int> r(o, o + 3);
      do {
        d = min(d, max(a / ng[r[0]], max(b / ng[r[1]], c / ng[r[2]])) -
                       min(a / ng[r[0]], min(b / ng[r[1]], c / ng[r[2]])));
      } while (next_permutation(r.begin(), r.end()));
      if (d < res) res = d, symp = 0;
      if (d == res) {
        int r = 0;
        for (int i = 0; i < 7; i++)
          for (int j = 0; j < 7; j++)
            if (group[i] == group[j]) r += likes[i][j];
        symp = max(r, symp);
      }
    }
  } else
    for (int i = 0; i < 3; i++) {
      group[lev] = i, ng[i]++;
      go(lev + 1);
      ng[i]--;
    }
}
int main() {
  int i, j, k, n;
  cin >> n;
  for (i = 0; i < n; i++) {
    string s1, s2, s3;
    cin >> s1 >> s3 >> s2;
    likes[getNum(s1)][getNum(s2)] = 1;
  }
  cin >> a >> b >> c;
  go(0);
  cout << res << " " << symp << endl;
  char ch;
  cin >> ch;
  return 0;
}
