#include <bits/stdc++.h>
using namespace std;
map<string, int> m;
int edge[100][100];
int use(int x, int y, int a[]) {
  int i;
  int j;
  int ct = 0;
  for (i = x; i <= y; i++) {
    for (j = x; j <= y; j++) {
      if (i != j && edge[a[i]][a[j]] == 1) ct++;
    }
  }
  return ct;
}
int check(int one, int two) {
  int v1, v2, v3;
  int ans = 0;
  int array[] = {0, 1, 2, 3, 4, 5, 6};
  do {
    v1 = use(0, one, array);
    v2 = use(one + 1, two, array);
    v3 = use(two + 1, 6, array);
    ans = max(ans, v1 + v2 + v3);
  } while (next_permutation(array, array + 7));
  return ans;
}
int main() {
  m["Anka"] = 0;
  m["Chapay"] = 1;
  m["Cleo"] = 2;
  m["Troll"] = 3;
  m["Dracul"] = 4;
  m["Snowy"] = 5;
  m["Hexadecimal"] = 6;
  int n, i;
  int v1, v2, v3;
  int j, k;
  int a, b, c;
  int exp1, exp2, exp3;
  int n1, n2, n3;
  string name1, temp, name2;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> name1 >> temp >> name2;
    edge[m[name1]][m[name2]] = 1;
  }
  cin >> a >> b >> c;
  int ans1, ans2;
  ans1 = 0;
  ans2 = 0;
  for (i = 0; i < 5; i++) {
    for (j = i + 1; j < 6; j++) {
      n1 = (i + 1);
      n2 = (j - i);
      n3 = (6 - j);
      exp1 = a / n1;
      exp2 = b / n2;
      exp3 = c / n3;
      if (i == 0 && j == 1)
        ans1 = max(exp1, max(exp2, exp3)) - min(exp1, min(exp2, exp3));
      else
        ans1 =
            min(ans1, max(exp1, max(exp2, exp3)) - min(exp1, min(exp2, exp3)));
    }
  }
  int val;
  for (i = 0; i < 5; i++) {
    for (j = i + 1; j < 6; j++) {
      n1 = (i + 1);
      n2 = (j - i);
      n3 = (6 - j);
      exp1 = a / n1;
      exp2 = b / n2;
      exp3 = c / n3;
      val = max(exp1, max(exp2, exp3)) - min(exp1, min(exp2, exp3));
      if (val == ans1) {
        ans2 = max(ans2, check(i, j));
      }
    }
  }
  cout << ans1 << " " << ans2 << endl;
  return 0;
}
