#include <bits/stdc++.h>
using namespace std;
int n, p1, p2, p3, graph[8][8];
int gibe(string x) {
  if (x[0] == 'C')
    if (x[1] == 'l')
      return 2;
    else
      return 3;
  else if (x[0] == 'T')
    return 1;
  else if (x[0] == 'A')
    return 4;
  else if (x[0] == 'D')
    return 5;
  else if (x[0] == 'S')
    return 6;
  else
    return 7;
}
int md = 1000000001, maxh = 0;
void read() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    string x, y, aux;
    cin >> x >> aux >> y;
    graph[gibe(x)][gibe(y)] = 1;
  }
  scanf("%d%d%d", &p1, &p2, &p3);
}
int bk[8];
void back(int k) {
  if (k == 8) {
    vector<int> f, s, t;
    for (int i = 1; i <= 7; ++i)
      if (bk[i] == 0)
        f.push_back(i);
      else if (bk[i] == 1)
        s.push_back(i);
      else
        t.push_back(i);
    if (s.size() == 0 || f.size() == 0 || t.size() == 0) return;
    int mx = p1 / f.size(), mn = p1 / f.size();
    mx = max(mx, p2 / (int)s.size());
    mx = max(mx, p3 / (int)t.size());
    mn = min(mn, p2 / (int)s.size());
    mn = min(mn, p3 / (int)t.size());
    int happy = 0;
    for (int i = 0; i < f.size(); ++i)
      for (int j = 0; j < f.size(); ++j) happy += graph[f[i]][f[j]];
    for (int i = 0; i < s.size(); ++i)
      for (int j = 0; j < s.size(); ++j) happy += graph[s[i]][s[j]];
    for (int i = 0; i < t.size(); ++i)
      for (int j = 0; j < t.size(); ++j) happy += graph[t[i]][t[j]];
    if (md > mx - mn) {
      md = mx - mn;
      maxh = happy;
    } else if (md == mx - mn) {
      maxh = max(maxh, happy);
    }
    return;
  }
  for (int i = 0; i <= 2; ++i) {
    bk[k] = i;
    back(k + 1);
  }
  return;
}
void write() { printf("%d %d", md, maxh); }
int main() {
  read();
  back(1);
  write();
  return 0;
}
