#include <bits/stdc++.h>
using namespace std;
const string name[7] = {"Anka",   "Chapay", "Cleo",       "Troll",
                        "Dracul", "Snowy",  "Hexadecimal"};
set<pair<string, string> > S;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string s1, s, s2;
    cin >> s1 >> s >> s2;
    S.insert(pair<string, string>(s1, s2));
  }
  int a[3];
  int idx[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  int ret = 999999999;
  int g[3];
  int cnt = 0;
  for (g[0] = 1; g[0] <= 5; g[0]++)
    for (g[1] = 1; g[0] + g[1] <= 6; g[1]++) {
      g[2] = 7 - g[0] - g[1];
      int delta[3];
      delta[0] = a[0] / g[0];
      delta[1] = a[1] / g[1];
      delta[2] = a[2] / g[2];
      sort(delta, delta + 3);
      if (delta[2] - delta[0] <= ret) {
        if (delta[2] - delta[0] < ret) {
          ret = delta[2] - delta[0];
          cnt = 0;
        }
        idx[0] = g[0];
        idx[1] = g[0] + g[1];
        int p[7] = {0, 1, 2, 3, 4, 5, 6};
        do {
          int tmp = 0;
          for (int i = 0; i < idx[0]; i++)
            for (int j = 0; j < idx[0]; j++)
              if (S.find(pair<string, string>(name[p[i]], name[p[j]])) !=
                  S.end())
                tmp++;
          for (int i = idx[0]; i < idx[1]; i++)
            for (int j = idx[0]; j < idx[1]; j++)
              if (S.find(pair<string, string>(name[p[i]], name[p[j]])) !=
                  S.end())
                tmp++;
          for (int i = idx[1]; i < 7; i++)
            for (int j = idx[1]; j < 7; j++)
              if (S.find(pair<string, string>(name[p[i]], name[p[j]])) !=
                  S.end())
                tmp++;
          if (tmp > cnt) cnt = tmp;
        } while (next_permutation(p, p + 7));
      }
    }
  cout << ret << " " << cnt << endl;
}
