#include <bits/stdc++.h>
using namespace std;
int num(char s[20]) {
  if (s[0] == 'A') return 0;
  if (s[0] == 'T') return 1;
  if (s[0] == 'D') return 2;
  if (s[0] == 'S') return 3;
  if (s[0] == 'H') return 4;
  if (s[1] == 'h') return 5;
  return 6;
}
int main() {
  int n, i, mm[7][7];
  memset(mm, 0, sizeof(mm));
  char s1[20], t[20], s2[20];
  cin >> n;
  for (i = 0; i < n; ++i) {
    cin >> s1 >> t >> s2;
    mm[num(s1)][num(s2)] = 1;
  }
  long long X[3];
  cin >> X[0] >> X[1] >> X[2];
  long long m[10], j, f, mt[3], min, max, res = (2147483647), r2 = 0;
  res *= 1000;
  memset(m, 0, sizeof(m));
  while (1) {
    j = 0;
    while (m[j] == 2) {
      m[j] = 0;
      ++j;
    }
    ++m[j];
    if (j == 7) break;
    f = 0;
    for (i = 0; i < 7; ++i) f |= (1 << m[i]);
    if (f != 7) continue;
    memset(mt, 0, sizeof(mt));
    for (i = 0; i < 7; ++i) ++mt[m[i]];
    min = (2147483647);
    max = -1;
    min *= 1000;
    for (i = 0; i < 7; ++i) {
      min = (((min) < (X[m[i]] / mt[m[i]])) ? (min) : (X[m[i]] / mt[m[i]]));
      max = (((max) > (X[m[i]] / mt[m[i]])) ? (max) : (X[m[i]] / mt[m[i]]));
    }
    if (res >= max - min) {
      if (res > max - min) r2 = 0;
      res = max - min;
      f = 0;
      for (i = 0; i < 7; ++i)
        for (j = 0; j < 7; ++j) f += mm[i][j] * (m[i] == m[j]);
      r2 = (((r2) > (f)) ? (r2) : (f));
    }
  }
  cout << res << " " << r2;
  return 0;
}
