#include <bits/stdc++.h>
using namespace std;
map<string, int> m;
int e[10][10];
int q[10];
int a[3];
int r[3];
int tt[3];
pair<int, int> chk() {
  memset(r, 0, sizeof(r));
  for (int i = 0; i < 7; ++i) r[q[i]]++;
  int t = 0;
  for (int i = 0; i < 7; ++i)
    for (int j = 0; j < 7; ++j)
      if (q[i] == q[j]) t += e[i][j];
  for (int i = 0; i < 3; ++i)
    if (r[i] == 0) return make_pair(2000000000, 2000000000);
  for (int i = 0; i < 3; ++i) tt[i] = a[i] / r[i];
  sort(tt, tt + 3);
  return make_pair(tt[2] - tt[0], -t);
}
pair<int, int> res = make_pair(2000000000, 2000000000);
void gen(int pos) {
  if (pos == 7) {
    res = min(res, chk());
    return;
  }
  for (int i = 0; i < 3; ++i) {
    q[pos] = i;
    gen(pos + 1);
  }
}
int main() {
  memset(e, 0, sizeof(e));
  m["Anka"] = 0;
  m["Chapay"] = 1;
  m["Cleo"] = 2;
  m["Troll"] = 3;
  m["Dracul"] = 4;
  m["Snowy"] = 5;
  m["Hexadecimal"] = 6;
  int n;
  cin >> n;
  string s1, s2, s3;
  for (int i = 0; i < n; ++i) {
    cin >> s1 >> s2 >> s3;
    e[m[s1]][m[s3]] = 1;
  }
  cin >> a[0] >> a[1] >> a[2];
  gen(0);
  cout << res.first << " " << -res.second << endl;
  return 0;
}
