#include <bits/stdc++.h>
const int INF = 2147483647;
using namespace std;
unsigned char like[7][7];
int fenzu[7];
int n, totjy[3];
int getnum(char l[50]) {
  switch (l[0]) {
    case 'A':
      return 0;
    case 'C':
      if (l[1] == 'h')
        return 1;
      else
        return 2;
    case 'T':
      return 3;
    case 'D':
      return 4;
    case 'S':
      return 5;
    case 'H':
      return 6;
  }
}
void init_and_read() {
  int i;
  char pa[50], pb[50];
  scanf("%d", &n);
  memset(like, 0, sizeof(like));
  for (i = 1; i <= n; i++) {
    scanf("%s likes %s", &pa, &pb);
    like[getnum(pa)][getnum(pb)] = 1;
  }
  for (i = 0; i < 3; i++) scanf("%d", &totjy[i]);
}
void Dec_To_Three(int x) {
  int i = 0;
  while (i < 7) {
    fenzu[i] = x % 3;
    x /= 3;
    i++;
  }
}
int Abs(int x) { return (x > 0) ? x : (-x); }
int max(int a, int b, int c) {
  a = (a > b) ? a : b;
  return (a > c) ? a : c;
}
void solve_and_print() {
  int i, j, k, flag, peplo[3], jingyan[3], minidif = INF, maxlike = -INF;
  int tmp, totlike;
  for (i = 0; i <= 2186; i++) {
    Dec_To_Three(i);
    peplo[0] = peplo[1] = peplo[2] = 0;
    for (j = 0; j <= 6; j++) {
      peplo[fenzu[j]]++;
    }
    flag = 0;
    for (j = 0; j <= 2; j++) {
      if (!peplo[j]) {
        flag = 1;
        break;
      }
      jingyan[j] = totjy[j] / peplo[j];
    }
    if (flag) continue;
    tmp = max(Abs(jingyan[0] - jingyan[1]), Abs(jingyan[0] - jingyan[2]),
              Abs(jingyan[1] - jingyan[2]));
    if (tmp < minidif) {
      minidif = tmp;
      maxlike = -INF;
    }
    if (tmp == minidif) {
      totlike = 0;
      for (j = 0; j <= 6; j++) {
        for (k = 0; k <= 6; k++) {
          if ((fenzu[j] == fenzu[k]) && (like[j][k])) {
            totlike++;
          }
        }
      }
    }
    if (totlike > maxlike) maxlike = totlike;
  }
  printf("%d %d\n", minidif, maxlike);
}
int main() {
  init_and_read();
  solve_and_print();
  return 0;
}
