#include <bits/stdc++.h>
using namespace std;
template <typename T>
string tostr(const T& t) {
  ostringstream os;
  os << t;
  return os.str();
}
long long big = 10000000;
int N;
vector<string> H;
map<pair<string, string>, bool> likes;
int A, B, C;
int main() {
  cin >> N;
  H.push_back("Anka");
  H.push_back("Chapay");
  H.push_back("Cleo");
  H.push_back("Troll");
  H.push_back("Dracul");
  H.push_back("Snowy");
  H.push_back("Hexadecimal");
  sort((H).begin(), (H).end());
  for (int i = (int)(0); i <= (int)(N - 1); ++i) {
    string p, tmp, q;
    cin >> p >> tmp >> q;
    likes[pair<string, string>(p, q)] = true;
  }
  cin >> A >> B >> C;
  long long bestLike = -1e25;
  long long bestDiff = 1e25;
  for (int i1 = (int)(0); i1 <= (int)(2); ++i1) {
    for (int i2 = (int)(0); i2 <= (int)(2); ++i2) {
      for (int i3 = (int)(0); i3 <= (int)(2); ++i3) {
        for (int i4 = (int)(0); i4 <= (int)(2); ++i4) {
          for (int i5 = (int)(0); i5 <= (int)(2); ++i5) {
            for (int i6 = (int)(0); i6 <= (int)(2); ++i6) {
              for (int i7 = (int)(0); i7 <= (int)(2); ++i7) {
                vector<string> team1, team2, team3;
                if (i1 == 0)
                  team1.push_back("Anka");
                else if (i1 == 1)
                  team2.push_back("Anka");
                else
                  team3.push_back("Anka");
                if (i2 == 0)
                  team1.push_back("Chapay");
                else if (i2 == 1)
                  team2.push_back("Chapay");
                else
                  team3.push_back("Chapay");
                if (i3 == 0)
                  team1.push_back("Cleo");
                else if (i3 == 1)
                  team2.push_back("Cleo");
                else
                  team3.push_back("Cleo");
                if (i4 == 0)
                  team1.push_back("Dracul");
                else if (i4 == 1)
                  team2.push_back("Dracul");
                else
                  team3.push_back("Dracul");
                if (i5 == 0)
                  team1.push_back("Snowy");
                else if (i5 == 1)
                  team2.push_back("Snowy");
                else
                  team3.push_back("Snowy");
                if (i6 == 0)
                  team1.push_back("Hexadecimal");
                else if (i6 == 1)
                  team2.push_back("Hexadecimal");
                else
                  team3.push_back("Hexadecimal");
                if (i7 == 0)
                  team1.push_back("Troll");
                else if (i7 == 1)
                  team2.push_back("Troll");
                else
                  team3.push_back("Troll");
                if (team1.empty() || team2.empty() || team3.empty()) continue;
                long long like = 0;
                for (int i = (int)(0); i <= (int)((int)team1.size() - 1); ++i) {
                  for (int j = (int)(0); j <= (int)((int)team1.size() - 1);
                       ++j) {
                    like += likes[make_pair(team1[i], team1[j])];
                  }
                }
                for (int i = (int)(0); i <= (int)((int)team2.size() - 1); ++i) {
                  for (int j = (int)(0); j <= (int)((int)team2.size() - 1);
                       ++j) {
                    like += likes[make_pair(team2[i], team2[j])];
                  }
                }
                for (int i = (int)(0); i <= (int)((int)team3.size() - 1); ++i) {
                  for (int j = (int)(0); j <= (int)((int)team3.size() - 1);
                       ++j) {
                    like += likes[make_pair(team3[i], team3[j])];
                  }
                }
                vector<int> order;
                order.push_back(A);
                order.push_back(B);
                order.push_back(C);
                sort((order).begin(), (order).end());
                do {
                  long long t1exp, t2exp, t3exp = 0;
                  t1exp = (double)order[0] / (double)(int)team1.size();
                  t2exp = (double)order[1] / (double)(int)team2.size();
                  t3exp = (double)order[2] / (double)(int)team3.size();
                  long long mn = 1e25;
                  long long mx = -1e25;
                  mn = min(mn, t1exp);
                  mn = min(mn, t2exp);
                  mn = min(mn, t3exp);
                  mx = max(mx, t1exp);
                  mx = max(mx, t2exp);
                  mx = max(mx, t3exp);
                  if (mx < mn) swap(mx, mn);
                  long long diff = mx - mn;
                  if (diff < bestDiff) {
                    bestDiff = diff;
                    bestLike = like;
                  } else if (diff == bestDiff && like > bestLike) {
                    bestLike = like;
                  }
                } while (next_permutation((order).begin(), (order).end()));
              }
            }
          }
        }
      }
    }
  }
  cout << bestDiff << " " << bestLike << endl;
  return 0;
}
