#include <bits/stdc++.h>
using namespace std;
map<string, int> nums;
int liking[7][7];
bool usable[7];
int team[7];
vector<int> members[3];
int mindifference, maxliking;
int a, b, c;
void teaming(int currteam, int memberno) {
  int i, j, t;
  if (currteam == 2 && memberno == 7) {
    int exp1 = a / members[0].size(), exp2 = b / members[1].size(),
        exp3 = c / members[2].size();
    int minexp = min(exp1, min(exp2, exp3));
    int maxexp = max(exp1, max(exp2, exp3));
    int diff = maxexp - minexp;
    int lliking = 0;
    for (t = 0; t < 3; t++) {
      for (i = 0; i < members[t].size(); i++) {
        for (j = 0; j < 7; j++) {
          if (liking[members[t][i]][j] == 1 && team[j] == t &&
              team[members[t][i]] == t)
            lliking++;
        }
      }
    }
    if (diff < mindifference ||
        (diff == mindifference && lliking > maxliking)) {
      mindifference = diff;
      maxliking = lliking;
    }
    return;
  }
  if (memberno >= 7) return;
  for (i = 0; i < 7; i++)
    if (usable[i]) {
      usable[i] = false;
      team[i] = currteam;
      members[currteam].push_back(i);
      teaming(currteam, memberno + 1);
      members[currteam].pop_back();
      if (currteam < 2 && members[currteam].size() > 0) {
        team[i] = currteam + 1;
        members[currteam + 1].push_back(i);
        teaming(currteam + 1, memberno + 1);
        members[currteam + 1].pop_back();
      }
      team[i] = -1;
      usable[i] = true;
    }
}
int main() {
  int i, j, n;
  nums.insert(make_pair("Anka", 0));
  nums.insert(make_pair("Chapay", 1));
  nums.insert(make_pair("Cleo", 2));
  nums.insert(make_pair("Troll", 3));
  nums.insert(make_pair("Dracul", 4));
  nums.insert(make_pair("Snowy", 5));
  nums.insert(make_pair("Hexadecimal", 6));
  scanf("%d", &n);
  for (i = 0; i < 7; i++)
    for (j = 0; j < 7; j++) liking[i][j] = 0;
  for (i = 0; i < 7; i++) {
    usable[i] = true;
    team[i] = -1;
  }
  for (i = 0; i < n; i++) {
    char name1[30], tmp[30], name2[30];
    scanf("%s %s %s", name1, tmp, name2);
    liking[nums[name1]][nums[name2]] = 1;
  }
  scanf("%d %d %d", &a, &b, &c);
  mindifference = 2000000000;
  maxliking = 0;
  teaming(0, 0);
  printf("%d %d", mindifference, maxliking);
  return 0;
}
