#include <bits/stdc++.h>
using namespace std;
int mp[10][10];
int Trans(char *str) {
  switch (str[0]) {
    case 'A':
      return 0;
    case 'C':
      if (str[1] == 'h')
        return 1;
      else
        return 2;
    case 'T':
      return 3;
    case 'D':
      return 4;
    case 'S':
      return 5;
    case 'H':
      return 6;
  }
}
int a, b, c;
int ans1, ans2;
int flag[10];
int num[3];
void dfs(int x) {
  if (x == 7) {
    num[0] = num[1] = num[2] = 0;
    for (int i = 0; i < 7; i++) {
      num[flag[i]]++;
    }
    if (num[0] && num[1] && num[2]) {
      int mn, mx, tmp = 0;
      mn = mx = a / num[0];
      if (mn > b / num[1]) mn = b / num[1];
      if (mx < b / num[1]) mx = b / num[1];
      if (mn > c / num[2]) mn = c / num[2];
      if (mx < c / num[2]) mx = c / num[2];
      for (int i = 0; i < 7; i++)
        for (int j = 0; j < 7; j++)
          if (flag[i] == flag[j] && mp[i][j]) tmp++;
      if (mx - mn < ans1) {
        ans1 = mx - mn;
        ans2 = tmp;
      } else if (mx - mn == ans1 && tmp > ans2)
        ans2 = tmp;
    }
    return;
  }
  for (int i = 0; i < 3; i++) {
    flag[x] = i;
    dfs(x + 1);
  }
}
int main() {
  int n;
  char ha[20], hb[20], tmp[20];
  while (scanf("%d", &n) != EOF) {
    memset(mp, 0, sizeof(mp));
    for (int i = 0; i < n; i++) {
      scanf("%s%s%s", ha, tmp, hb);
      mp[Trans(ha)][Trans(hb)] = 1;
    }
    scanf("%d%d%d", &a, &b, &c);
    ans1 = (1 << 30), ans2 = 0;
    dfs(0);
    printf("%d %d\n", ans1, ans2);
  }
}
