#include <bits/stdc++.h>
using namespace std;
const string arr[7] = {"Troll", "Dracul", "Anka",       "Chapay",
                       "Cleo",  "Snowy",  "Hexadecimal"};
int g[7][7];
int x[3];
int p[7];
int res = 0;
int ans = INT_MAX;
int get(string s) {
  for (int i = 0; i < 7; i++) {
    if (s == arr[i]) return i;
  }
  return -1;
}
void go(int i) {
  if (i == 7) {
    int group[3];
    group[0] = 0;
    group[1] = 0;
    group[2] = 0;
    for (int i = 0; i < 7; i++) {
      group[p[i]]++;
    }
    if (group[0] * group[1] * group[2] == 0) return;
    int mn = min(x[0] / group[0], min(x[1] / group[1], x[2] / group[2]));
    int mx = max(x[0] / group[0], max(x[1] / group[1], x[2] / group[2]));
    int temp = 0;
    for (int k = 0; k < 7; k++) {
      for (int l = 0; l < 7; l++) {
        if (p[k] == p[l] && g[k][l] == 1) temp++;
      }
    }
    if (mx - mn < ans || (mx - mn == ans && res < temp)) {
      ans = mx - mn;
      res = temp;
    }
    return;
  }
  for (int j = 0; j < 3; j++) {
    p[i] = j;
    go(i + 1);
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string a, b, c;
    cin >> a >> b >> c;
    g[get(a)][get(c)] = 1;
  }
  for (int i = 0; i < 3; i++) cin >> x[i];
  go(0);
  cout << ans << " " << res;
}
