#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const long long INF = 2000000000000000000;
const char *in_file = "input.txt";
const char *out_file = "output.txt";
int n, m;
map<string, int> names;
vector<vector<int>> likes(7, vector<int>(7));
vector<long long> c(3);
int main() {
  names["Anka"] = 0;
  names["Chapay"] = 1;
  names["Cleo"] = 2;
  names["Troll"] = 3;
  names["Dracul"] = 4;
  names["Snowy"] = 5;
  names["Hexadecimal"] = 6;
  cin >> n;
  string line;
  getline(cin, line);
  for (int _n(n), i(0); i < _n; i++) {
    getline(cin, line);
    int pos = line.find_first_of(" ");
    int a = names[line.substr(0, pos)];
    pos = line.find_last_of(" ");
    int b = names[line.substr(pos + 1, line.size() - pos)];
    likes[a][b] = 1;
  }
  for (int _n(3), i(0); i < _n; i++) cin >> c[i];
  sort((c).begin(), (c).end());
  vector<vector<int>> pos(4, vector<int>(3));
  pos[0][0] = 1;
  pos[0][1] = 1;
  pos[0][2] = 5;
  pos[1][0] = 1;
  pos[1][1] = 2;
  pos[1][2] = 4;
  pos[2][0] = 1;
  pos[2][1] = 3;
  pos[2][2] = 3;
  pos[3][0] = 2;
  pos[3][1] = 2;
  pos[3][2] = 3;
  int bestPos = 0;
  int bestScore = INF;
  int count = 0;
  int a1, a2, a3;
  map<int, int> sc;
  for (int _n(4), i(0); i < _n; i++) {
    vector<int> p;
    for (int _n(pos[i][0]), j(0); j < _n; j++) p.push_back(1);
    for (int _n(pos[i][1]), j(0); j < _n; j++) p.push_back(2);
    for (int _n(pos[i][2]), j(0); j < _n; j++) p.push_back(3);
    sort((p).begin(), (p).end());
    vector<int> s(3);
    for (int _n(3), j(0); j < _n; j++) s[j] = c[j];
    do {
      a1 = c[0] / pos[i][0];
      a2 = c[1] / pos[i][1];
      a3 = c[2] / pos[i][2];
      if (max(max(a1, a2), a3) - min(min(a1, a2), a3) <= bestScore) {
        bestScore = max(max(a1, a2), a3) - min(min(a1, a2), a3);
        do {
          int res = 0;
          for (int _n(p.size()), k(0); k < _n; k++) {
            int g = p[k];
            for (int _n(p.size()), k2(0); k2 < _n; k2++)
              if (p[k2] == g) res += likes[k][k2];
          }
          if (res > sc[bestScore]) sc[bestScore] = res;
        } while (next_permutation(p.begin(), p.end()));
      }
    } while (next_permutation(s.begin(), s.end()));
  }
  cout << bestScore << " " << sc[bestScore] << endl;
}
