#include <bits/stdc++.h>
using namespace std;
struct times {
  long long a, b, c;
};
int main() {
  long long n;
  cin >> n;
  map<string, int> ids;
  ids["Anka"] = 0;
  ids["Chapay"] = 1;
  ids["Cleo"] = 2;
  ids["Troll"] = 3;
  ids["Dracul"] = 4;
  ids["Snowy"] = 5;
  ids["Hexadecimal"] = 6;
  long long matrix[10][10];
  memset(matrix, 0, sizeof(matrix));
  for (int i = 0; i < n; i++) {
    string a, b, c;
    cin >> a >> b >> c;
    matrix[ids[a]][ids[c]] = 1;
  }
  long long m1, m2, m3;
  cin >> m1 >> m2 >> m3;
  long long ans = 1e10;
  vector<times> check;
  for (long long i = 1; i <= 5; i++) {
    for (long long j = 1; j + i <= 6; j++) {
      long long k = 7 - i - j;
      long long x = m1 / i;
      long long y = m2 / j;
      long long z = m3 / k;
      long long mn = min({x, y, z});
      long long mx = max({x, y, z});
      if (mx - mn < ans) {
        check.clear();
        ans = mx - mn;
        times node;
        node.a = i;
        node.b = j;
        node.c = k;
        check.push_back(node);
      } else if (mx - mn == ans) {
        times node;
        node.a = i;
        node.b = j;
        node.c = k;
        check.push_back(node);
      }
    }
  }
  long long ans2 = 0;
  for (auto x : check) {
    long long all[7] = {0, 1, 2, 3, 4, 5, 6};
    long long an = x.a, bn = x.b;
    do {
      long long c = 0;
      for (long long i = 0; i < an; i++) {
        for (long long j = 0; j < an; j++) {
          c = c + matrix[all[i]][all[j]];
        }
      }
      for (long long i = an; i < an + bn; i++) {
        for (long long j = an; j < an + bn; j++) {
          c = c + matrix[all[i]][all[j]];
        }
      }
      for (long long i = an + bn; i < 7; i++) {
        for (long long j = an + bn; j < 7; j++) {
          c = c + matrix[all[i]][all[j]];
        }
      }
      ans2 = max(ans2, c);
    } while (next_permutation(all, all + 7));
  }
  cout << ans << " " << ans2;
  return 0;
}
