#include <bits/stdc++.h>
using namespace std;
map<pair<long long int, long long int>, long long int> mp;
long long int na, nb, nc;
long long int mx;
int BF(long long int i, long long int x, long long int y, long long int z,
       long long int m[]) {
  if (i == 8) {
    long long int cn = 0;
    for (int j = 1; j <= 7; j++) {
      for (int k = j + 1; k <= 7; k++) {
        if (m[j] == m[k]) {
          if (mp[make_pair(j, k)] == 1) cn++;
          if (mp[make_pair(k, j)] == 1) cn++;
        }
      }
    }
    mx = max(mx, cn);
    return 0;
  }
  if (x != na) {
    m[i] = 1;
    BF(i + 1, x + 1, y, z, m);
    m[i] = 0;
  }
  if (y != nb) {
    m[i] = 2;
    BF(i + 1, x, y + 1, z, m);
    m[i] = 0;
  }
  if (z != nc) {
    m[i] = 3;
    BF(i + 1, x, y, z + 1, m);
    m[i] = 0;
  }
  return 0;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string x, w, y;
    cin >> x >> w >> y;
    long long int nx, ny;
    if (x == "Anka")
      nx = 1;
    else if (x == "Chapay")
      nx = 2;
    else if (x == "Cleo")
      nx = 3;
    else if (x == "Troll")
      nx = 4;
    else if (x == "Dracul")
      nx = 5;
    else if (x == "Snowy")
      nx = 6;
    else
      nx = 7;
    if (y == "Anka")
      ny = 1;
    else if (y == "Chapay")
      ny = 2;
    else if (y == "Cleo")
      ny = 3;
    else if (y == "Troll")
      ny = 4;
    else if (y == "Dracul")
      ny = 5;
    else if (y == "Snowy")
      ny = 6;
    else
      ny = 7;
    mp[make_pair(nx, ny)] = 1;
  }
  long long int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  long long int mn = 2000000000000000;
  long long int mxxx = 0;
  for (int i = 1; i <= 7; i++) {
    for (int j = 1; j <= 7; j++) {
      for (int k = 1; k <= 7; k++) {
        if (i + j + k == 7) {
          long long int ba = a[0] / i;
          long long int bb = a[1] / j;
          long long int bc = a[2] / k;
          long long int mxx =
              ba > bb ? (ba > bc ? ba : bc) : (bb > bc ? bb : bc);
          long long int mnn =
              ba < bb ? (ba < bc ? ba : bc) : (bb < bc ? bb : bc);
          if (mxx - mnn <= mn) {
            na = i;
            nb = j;
            nc = k;
            mx = 0;
            long long int m[10];
            memset(m, 0, sizeof(m));
            BF(1, 0, 0, 0, m);
            if (mxx - mnn < mn)
              mxxx = mx;
            else if (mxx - mnn == mn)
              mxxx = max(mxxx, mx);
            mn = mxx - mnn;
          }
        }
      }
    }
  }
  cout << mn << " " << mxxx;
  return 0;
}
