#include <bits/stdc++.h>
using namespace std;
map<string, int> name2id;
bool like[10][10];
int score[3];
int belong[7];
int minDiff;
int maxLike;
void search(int depth) {
  if (depth == 7) {
    int cnt[3];
    memset(cnt, 0, sizeof(cnt));
    for (int i = 0; i < 7; ++i) cnt[belong[i]]++;
    for (int i = 0; i < 3; ++i)
      if (cnt[i] == 0) return;
    int s[3];
    memset(s, 0, sizeof(s));
    for (int i = 0; i < 3; ++i) s[i] = score[i] / cnt[i];
    int maxs = -1;
    int mins = 2100000000;
    for (int i = 0; i < 3; ++i) {
      maxs = max(maxs, s[i]);
      mins = min(mins, s[i]);
    }
    int nowdiff = maxs - mins;
    int nowlike = 0;
    for (int i = 0; i < 7; ++i)
      for (int j = 0; j < 7; ++j)
        if (like[i][j] && belong[i] == belong[j]) nowlike++;
    if (nowdiff < minDiff) {
      minDiff = nowdiff;
      maxLike = nowlike;
    }
    if (nowdiff == minDiff && nowlike > maxLike) {
      maxLike = nowlike;
    }
    return;
  }
  for (int i = 0; i < 3; ++i) {
    belong[depth] = i;
    search(depth + 1);
  }
}
void york() {
  minDiff = 2100000000;
  maxLike = -1;
  search(0);
  cout << minDiff << " " << maxLike << endl;
}
void init() {
  name2id["Anka"] = 0;
  name2id["Chapay"] = 1;
  name2id["Cleo"] = 2;
  name2id["Troll"] = 3;
  name2id["Dracul"] = 4;
  name2id["Snowy"] = 5;
  name2id["Hexadecimal"] = 6;
  int N;
  memset(like, false, sizeof(like));
  cin >> N;
  for (int i = 0; i < N; ++i) {
    string t1, t2, t3;
    cin >> t1 >> t2 >> t3;
    like[name2id[t1]][name2id[t3]] = true;
  }
  cin >> score[0] >> score[1] >> score[2];
}
int main() {
  init();
  york();
  return 0;
}
