#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
char name[10][100];
bool g[10][10];
int cnt = 0;
int insert(char *in) {
  int i;
  for (i = 0; i < cnt; ++i) {
    if (!strcmp(name[i], in)) {
      return i;
    }
  }
  if (i == cnt) {
    strcpy(name[cnt], in);
  }
  return cnt++;
}
int ccnt[3];
int vis[10];
int ret;
void dfs(int p);
void ddfs(int c, int p) {
  if (c == ccnt[p]) {
    dfs(p + 1);
    return;
  } else {
    for (int i = 0; i < 7; ++i) {
      if (vis[i] == -1) {
        vis[i] = p;
        ddfs(c + 1, p);
        vis[i] = -1;
      }
    }
  }
  return;
}
void dfs(int p) {
  if (p == 2) {
    int tmp = 0;
    for (int i = 0; i < 7; ++i)
      for (int j = 0; j < 7; ++j) {
        if (vis[i] == vis[j] && g[i][j]) tmp++;
      }
    ret = max(tmp, ret);
    return;
  } else {
    ddfs(0, p);
  }
  return;
}
int acount(int a, int b, int c) {
  ccnt[0] = a;
  ccnt[1] = b;
  ccnt[2] = c;
  ret = 0;
  memset(vis, -1, sizeof(vis));
  dfs(0);
  return ret;
}
int main() {
  int n;
  scanf("%d", &n);
  char in1[100], in2[100];
  for (int i = 0; i < n; ++i) {
    scanf("%s %*s %s", in1, in2);
    int f = insert(in1);
    int t = insert(in2);
    g[f][t] = true;
  }
  int point[3];
  scanf("%d %d %d", point, point + 1, point + 2);
  int a = 1, b = 1, c;
  int ans1 = INF;
  int ans2;
  for (a = 1; a < 7; ++a)
    for (b = 1; b + a < 7; ++b) {
      c = 7 - a - b;
      int t1 = point[0] / a;
      int t2 = point[1] / b;
      int t3 = point[2] / c;
      int maxx = max(t1, max(t2, t3));
      int minx = min(t1, min(t2, t3));
      if (maxx - minx < ans1) {
        ans1 = maxx - minx;
        ans2 = acount(a, b, c);
      } else if (maxx - minx == ans1) {
        ans1 = maxx - minx;
        ans2 = max(ans2, acount(a, b, c));
      }
    }
  printf("%d %d\n", ans1, ans2);
  return 0;
}
