#include <bits/stdc++.h>
using namespace std;
struct Yal {
  string s1, s2;
};
bool operator<(Yal a, Yal b) {
  if (a.s1 != b.s1) return a.s1 < b.s1;
  return a.s2 < b.s2;
}
int n;
int a, b, c;
map<Yal, bool> mark;
string Heroes[7] = {"Anka",   "Chapay", "Cleo",       "Troll",
                    "Dracul", "Snowy",  "Hexadecimal"};
vector<string> Group[3];
const int INF = 2000 * 1000 * 1000;
int min_ekh = INF, most_like = -1;
int LIKES() {
  int like = 0;
  for (int j = 0; j < 3; j++) {
    for (int i1 = 0; i1 < (int)Group[j].size(); i1++)
      for (int i2 = 0; i2 < (int)Group[j].size(); i2++) {
        if (i1 == i2) continue;
        Yal y;
        y.s1 = Group[j][i1];
        y.s2 = Group[j][i2];
        if (mark[y]) like++;
      }
  }
  return like;
}
int EKH() {
  int mx = -1;
  int mn = INF;
  int h1 = a / Group[0].size();
  mx = max(mx, h1);
  mn = min(mn, h1);
  int h2 = b / Group[1].size();
  mx = max(mx, h2);
  mn = min(mn, h2);
  int h3 = c / Group[2].size();
  mx = max(mx, h3);
  mn = min(mn, h3);
  return mx - mn;
}
void Calc() {
  for (int i = 0; i < 3; i++)
    if (Group[i].size() == 0) return;
  int k = EKH();
  int l = LIKES();
  if (min_ekh == INF) {
    min_ekh = k;
    most_like = LIKES();
  }
  if (k == min_ekh) {
    most_like = max(most_like, LIKES());
  }
  if (k < min_ekh) {
    min_ekh = k;
    most_like = LIKES();
  }
}
void make(int i) {
  if (i > 6) {
    Calc();
    return;
  }
  for (int j = 0; j < 3; j++) {
    Group[j].push_back(Heroes[i]);
    make(i + 1);
    Group[j].pop_back();
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    string temp;
    Yal y;
    cin >> y.s1 >> temp >> y.s2;
    mark[y] = true;
  }
  cin >> a >> b >> c;
  make(0);
  cout << min_ekh << " " << most_like << endl;
}
