#include <bits/stdc++.h>
using namespace std;
int main() {
  map<string, int> m;
  m["Anka"] = 0, m["Chapay"] = 1, m["Cleo"] = 2, m["Troll"] = 3,
  m["Dracul"] = 4, m["Snowy"] = 5, m["Hexadecimal"] = 6;
  int n;
  cin >> n;
  bool t[7][7] = {};
  string someone, likes, somebody;
  for (int _n = 0; _n < n; ++_n) {
    cin >> someone >> likes >> somebody;
    t[m[someone]][m[somebody]] = true;
  }
  pair<int, int> best(0x7fffffff, 0);
  int a, b, c;
  cin >> a >> b >> c;
  int r[7] = {};
  for (r[0] = 0; r[0] < 3; ++r[0])
    for (r[1] = 0; r[1] < 3; ++r[1])
      for (r[2] = 0; r[2] < 3; ++r[2])
        for (r[3] = 0; r[3] < 3; ++r[3])
          for (r[4] = 0; r[4] < 3; ++r[4])
            for (r[5] = 0; r[5] < 3; ++r[5])
              for (r[6] = 0; r[6] < 3; ++r[6]) {
                int g[3] = {};
                for (int i = 0; i < 7; ++i) ++g[r[i]];
                if (!g[0] || !g[1] || !g[2]) continue;
                int diff = max(a / g[0], max(b / g[1], c / g[2])) -
                           min(a / g[0], min(b / g[1], c / g[2])),
                    cnt = 0;
                for (int i = 0; i < 7; ++i)
                  for (int j = 0; j < 7; ++j)
                    if (t[i][j] && r[i] == r[j]) ++cnt;
                best = min(best, make_pair(diff, -cnt));
              }
  cout << best.first << ' ' << -best.second << endl;
  return 0;
}
