#include <bits/stdc++.h>
using namespace std;
double eps = 1e-9;
const int INF = 1e9 + 7;
const int MAXN = int(2e5 + 7);
int n, a[3], sum, g[10][10], d[10], ans = INF * 2;
string second[7] = {"Anka",   "Chapay", "Cleo",       "Troll",
                    "Dracul", "Snowy",  "Hexadecimal"};
int get(string a) {
  for (int i = 0; i < 7; i++)
    if (second[i] == a) return i;
}
void check() {
  vector<int> v[3];
  for (int i = 0; i < 7; i++) v[d[i]].push_back(i);
  int maxi = 0, mini = INF * 2;
  for (int i = 0; i < 3; i++) {
    if (v[i].size() == 0) return;
    maxi = max(maxi, a[i] / (int)v[i].size());
    mini = min(mini, a[i] / (int)v[i].size());
  }
  int res = 0;
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < v[i].size(); j++)
      for (int k = 0; k < v[i].size(); k++) res += g[v[i][j]][v[i][k]];
  if (ans > maxi - mini)
    ans = maxi - mini, sum = res;
  else if (ans == maxi - mini && res > sum)
    sum = res;
}
void go(int x) {
  if (x == 7) {
    check();
    return;
  }
  for (int i = 0; i < 3; i++) {
    d[x] = i;
    go(x + 1);
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    string b[3];
    cin >> b[0] >> b[1] >> b[2];
    g[get(b[0])][get(b[2])] = 1;
  }
  cin >> a[0] >> a[1] >> a[2];
  go(0);
  cout << ans << " " << sum << endl;
  return 0;
}
