#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
clock_t clk = clock();
using namespace std;
int i, j, k;
void solve(void);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) solve();
  return 0;
}
map<pair<int, int>, bool> love;
void solve() {
  int n;
  cin >> n;
  string s[3];
  unordered_map<string, long long int> m;
  m["Anka"] = 1;
  m["Chapay"] = 2;
  m["Cleo"] = 3;
  m["Troll"] = 4;
  m["Dracul"] = 5;
  m["Snowy"] = 6;
  m["Hexadecimal"] = 7;
  for (i = 0; i <= n - 1; ++i) {
    cin >> s[0] >> s[1] >> s[2];
    love[make_pair(m[s[0]], m[s[2]])] = 1;
  }
  long long int b[3];
  cin >> b[0] >> b[1] >> b[2];
  sort(b, b + 3, greater<int>());
  long long int mi = 1000000007, tot = 0;
  vector<long long int> v[4];
  v[0].push_back(5);
  v[0].push_back(1);
  v[0].push_back(1);
  v[1].push_back(4);
  v[1].push_back(2);
  v[1].push_back(1);
  v[2].push_back(3);
  v[2].push_back(3);
  v[2].push_back(1);
  v[3].push_back(3);
  v[3].push_back(2);
  v[3].push_back(2);
  for (i = 0; i <= 3; ++i) {
    int a[7] = {1, 2, 3, 4, 5, 6, 7};
    long long int ct = 0;
    long long int val1 = b[0] / v[i][0], val2 = b[1] / v[i][1],
                  val3 = b[2] / v[i][2];
    ct = ((val1) > (val2) && (val1) > (val3) ? (val1)
          : (val2) > (val3)                  ? (val2)
                                             : (val3)) -
         ((val1) < (val2) && (val1) < (val3) ? (val1)
          : (val2) < (val3)                  ? (val2)
                                             : (val3));
    do {
      if (ct > mi)
        continue;
      else {
        long long int temp = 0;
        int ti = 0;
        for (int l = 0; l <= 2; ++l) {
          for (j = 0; j <= v[i][l] - 1; ++j)
            for (k = 0; k <= v[i][l] - 1; ++k)
              if (love[make_pair(a[ti + j], a[ti + k])] == 1) ++temp;
          ti += v[i][l];
        }
        if (mi > ct) {
          mi = ct;
          tot = temp;
        } else if (tot < temp)
          tot = temp;
      }
    } while (next_permutation(a, a + 7));
  }
  cout << "\n" << mi << " " << tot;
}
