#include <bits/stdc++.h>
using namespace std;
long long n, a[10][10], x1, x2, x3, tri = 2187, res1 = 1234567890, res2 = 0,
                                    was[10], kol = 7, t1, t2, YES[10];
string s[] = {"Anka",   "Chapay", "Cleo",       "Troll",
              "Dracul", "Snowy",  "Hexadecimal"};
void dfs(int s, int q) {
  ++t1;
  ++was[s];
  for (int i = 0; i < kol; ++i)
    if (YES[i] == q && a[s][i]) ++t2;
  for (int i = 0; i < kol; ++i)
    if (YES[i] == q && !was[i]) dfs(i, q);
}
int main() {
  scanf("%d", &n);
  memset(a, 0, sizeof a);
  for (int i = 0; i < n; ++i) {
    string name1, likes, name2;
    cin >> name1 >> likes >> name2;
    int x = 0, y = 0;
    for (int i = 0; i < kol; ++i)
      if (name1 == s[i]) x = i;
    for (int i = 0; i < kol; ++i)
      if (name2 == s[i]) y = i;
    a[x][y] = 1;
  }
  cin >> x1 >> x2 >> x3;
  for (int i = 0; i < tri; ++i) {
    int kol1 = 0, yes = 0;
    memset(YES, 0, sizeof YES);
    int num = i;
    while (num) {
      ++YES[kol1] = num % 3;
      num /= 3;
      ++kol1;
    }
    for (int i = 0; i < kol; ++i)
      if (YES[i] == 0) {
        ++yes;
        break;
      }
    for (int i = 0; i < kol; ++i)
      if (YES[i] == 1) {
        ++yes;
        break;
      }
    for (int i = 0; i < kol; ++i)
      if (YES[i] == 2) {
        ++yes;
        break;
      }
    if (yes == 3) {
      long long ex1, ex2, ex3, maxf = 0;
      t1 = 0, t2 = 0;
      for (int i = 0; i < kol; ++i)
        if (YES[i] == 0) {
          memset(was, 0, sizeof was);
          dfs(i, 0);
          break;
        }
      ex1 = x1 / t1;
      maxf += t2;
      t1 = 0, t2 = 0;
      for (int i = 0; i < kol; ++i)
        if (YES[i] == 1) {
          memset(was, 0, sizeof was);
          dfs(i, 1);
          break;
        }
      ex2 = x2 / t1;
      maxf += t2;
      t1 = 0, t2 = 0;
      for (int i = 0; i < kol; ++i)
        if (YES[i] == 2) {
          memset(was, 0, sizeof was);
          dfs(i, 2);
          break;
        }
      ex3 = x3 / t1;
      maxf += t2;
      long long maxex = max(ex1, max(ex2, ex3));
      long long minex = min(ex1, min(ex2, ex3));
      if (maxex - minex < res1) {
        res1 = maxex - minex;
        res2 = maxf;
      }
      if (maxex - minex == res1 && res2 < maxf) {
        res2 = maxf;
      }
    }
  }
  cout << res1 << ' ' << res2;
  return 0;
}
