#include <bits/stdc++.h>
using namespace std;
const string arr[7] = {"Anka",   "Chapay", "Cleo",       "Troll",
                       "Dracul", "Snowy",  "Hexadecimal"};
int get(string s) {
  for (int i = 0; i < 7; i++) {
    if (arr[i] == s) {
      return i;
    }
  }
}
bool likes[7][7];
int p[7], a[3], y[3];
int ans, numOfLikes;
void go(int x) {
  if (x == 7) {
    for (int i = 0; i < 3; i++) {
      y[i] = 0;
    }
    for (int i = 0; i < 7; i++) {
      y[p[i]]++;
    }
    if (y[0] && y[1] && y[2]) {
      int mdiff = min(a[0] / y[0], min(a[1] / y[1], a[2] / y[2]));
      int Mdiff = max(a[0] / y[0], max(a[1] / y[1], a[2] / y[2]));
      int num = 0;
      for (int i = 0; i < 7; i++) {
        for (int j = 0; j < 7; j++) {
          if (likes[i][j] && p[i] == p[j]) {
            num++;
          }
        }
      }
      if (Mdiff - mdiff < ans || Mdiff - mdiff == ans && num > numOfLikes) {
        ans = Mdiff - mdiff;
        numOfLikes = num;
      }
    }
  } else {
    for (int j = 0; j < 3; j++) {
      p[x] = j;
      go(x + 1);
    }
  }
}
int main() {
  ans = (int)2e9 + 1;
  numOfLikes = 0;
  string s1, s2;
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    cin >> s1 >> s2 >> s2;
    likes[get(s1)][get(s2)] = true;
  }
  for (int i = 0; i < 3; i++) {
    scanf("%d", &a[i]);
  }
  go(0);
  cout << ans << ' ' << numOfLikes << "\r\n";
  return 0;
}
