#include <bits/stdc++.h>
using namespace std;
map<string, int> M;
int graph[10][10];
void init() {
  M["Anka"] = 0;
  M["Chapay"] = 1;
  M["Troll"] = 2;
  M["Dracul"] = 3;
  M["Snowy"] = 4;
  M["Hexadecimal"] = 5;
  M["Cleo"] = 6;
}
int aabs(int x) {
  if (x < 0) x = -x;
  return x;
}
int main() {
  int n;
  string str, a, b, junk;
  init();
  memset(graph, 0, sizeof(graph));
  cin >> n;
  getchar();
  for (int i = (0); i < (n); i++) {
    getline(cin, str);
    istringstream ss(str);
    ss >> a >> junk >> b;
    graph[M[a]][M[b]] = 1;
  }
  int TA, TB, TC;
  cin >> TA >> TB >> TC;
  int best = -1, mindiff = 2000000000 + 7;
  for (int x = (1); x < (8); x++) {
    for (int y = (x + 1); y < (7); y++) {
      int z = 7;
      {
        int L = x, M = y - x, N = z - y;
        int Ga = TA / L, Gb = TB / M, Gc = TC / N;
        int best2, locbest = -1, cnt;
        best2 = max(aabs(Ga - Gb), max(aabs(Gb - Gc), aabs(Gc - Ga)));
        vector<int> V;
        for (int i = (0); i < (7); i++) V.push_back(i);
        do {
          cnt = 0;
          for (int i = (0); i < (x); i++)
            for (int j = (0); j < (x); j++)
              if (i != j)
                if (graph[V[i]][V[j]] == 1) cnt++;
          for (int i = (x); i < (y); i++)
            for (int j = (x); j < (y); j++)
              if (i != j)
                if (graph[V[i]][V[j]] == 1) cnt++;
          for (int i = (y); i < (z); i++)
            for (int j = (y); j < (z); j++)
              if (i != j)
                if (graph[V[i]][V[j]] == 1) cnt++;
          if (cnt > locbest) locbest = cnt;
        } while (next_permutation(V.begin(), V.end()));
        if (best2 < mindiff)
          mindiff = best2, best = locbest;
        else if (best2 == mindiff)
          best = max(locbest, best);
      }
    }
  }
  cout << mindiff << " " << best << endl;
}
