#include <bits/stdc++.h>
using namespace std;
bool store[7][7];
long long int x, y, z;
long long int m1, m2;
int ar[7];
long long int mx(long long int a, long long int b) { return a > b ? a : b; }
long long int mn(long long int a, long long int b) { return a < b ? a : b; }
void check() {
  int a[3], i, j;
  a[0] = a[1] = a[2] = 0;
  long long int l = 0;
  i = 0;
  while (i < 7) {
    a[ar[i]]++;
    j = i + 1;
    while (j < 7) {
      if (ar[i] == ar[j]) {
        if (store[i][j]) l++;
        if (store[j][i]) l++;
      }
      j++;
    }
    i++;
  }
  if (!(a[0] && a[1] && a[2])) return;
  long long int d, e, f, g, h;
  d = x / a[0];
  e = y / a[1];
  f = z / a[2];
  g = mx(d, mx(e, f));
  h = mn(d, mn(e, f));
  g -= h;
  if (g < m1) {
    m1 = g;
    m2 = l;
  } else if (g == m1)
    m2 = mx(m2, l);
}
void solve(int ind) {
  if (ind == 7) {
    check();
    return;
  }
  ar[ind] = 0;
  solve(ind + 1);
  ar[ind] = 1;
  solve(ind + 1);
  ar[ind] = 2;
  solve(ind + 1);
}
int main() {
  int n;
  cin >> n;
  string a, b, c;
  map<string, int> mp;
  mp["Anka"] = 0;
  mp["Chapay"] = 1;
  mp["Cleo"] = 2;
  mp["Troll"] = 3;
  mp["Dracul"] = 4;
  mp["Snowy"] = 5;
  mp["Hexadecimal"] = 6;
  long long int i, j, k;
  memset(store, false, sizeof(store));
  while (n--) {
    cin >> a >> b >> c;
    i = mp[a];
    j = mp[c];
    store[i][j] = true;
  }
  cin >> x >> y >> z;
  m1 = 2000000000LL;
  m2 = -1;
  solve(0);
  cout << m1 << " " << m2;
  return 0;
}
