#include <bits/stdc++.h>
using namespace std;
int d[100][100];
char s[10000];
int main() {
  int i, j, k, max, min, ans1, ans2, o, p, e1, e2, e3, tot, x, y, n;
  string name1, name2;
  map<string, int> mp;
  vector<string> a;
  vector<int> aa;
  scanf("%d", &n);
  mp.clear();
  a.clear();
  memset(d, 0, sizeof(d));
  for (i = 0; i < n; i++) {
    scanf("%s", s);
    name1 = s;
    scanf("%s", s);
    scanf("%s", s);
    name2 = s;
    if (mp.find(name1) == mp.end()) {
      mp[name1] = a.size();
      a.push_back(name1);
    }
    if (mp.find(name2) == mp.end()) {
      mp[name2] = a.size();
      a.push_back(name2);
    }
    d[mp[name1]][mp[name2]] = 1;
  }
  scanf("%d%d%d", &e1, &e2, &e3);
  ans1 = 2000000000;
  ans2 = 0;
  aa.clear();
  for (i = 0; i < 7; i++) aa.push_back(i);
  do {
    for (i = 1; i < 7; i++)
      for (j = 1; i + j < 7; j++) {
        k = 7 - i - j;
        max = -2000000000;
        min = 2000000000;
        if (e1 / i > max) max = e1 / i;
        if (e1 / i < min) min = e1 / i;
        if (e2 / j > max) max = e2 / j;
        if (e2 / j < min) min = e2 / j;
        if (e3 / k > max) max = e3 / k;
        if (e3 / k < min) min = e3 / k;
        if (max - min < ans1) ans1 = max - min;
      }
  } while (next_permutation(aa.begin(), aa.end()));
  aa.clear();
  for (i = 0; i < 7; i++) aa.push_back(i);
  do {
    for (i = 1; i < 7; i++)
      for (j = 1; i + j < 7; j++) {
        k = 7 - i - j;
        max = -2000000000;
        min = 2000000000;
        if (e1 / i > max) max = e1 / i;
        if (e1 / i < min) min = e1 / i;
        if (e2 / j > max) max = e2 / j;
        if (e2 / j < min) min = e2 / j;
        if (e3 / k > max) max = e3 / k;
        if (e3 / k < min) min = e3 / k;
        if (max - min == ans1) {
          tot = 0;
          x = 0;
          y = x + i - 1;
          for (o = x; o <= y; o++)
            for (p = x; p <= y; p++)
              if (d[aa[o]][aa[p]] == 1) tot++;
          x = i;
          y = x + j - 1;
          for (o = x; o <= y; o++)
            for (p = x; p <= y; p++)
              if (d[aa[o]][aa[p]] == 1) tot++;
          x = i + j;
          y = x + k - 1;
          for (o = x; o <= y; o++)
            for (p = x; p <= y; p++)
              if (d[aa[o]][aa[p]] == 1) tot++;
          if (tot > ans2) ans2 = tot;
        }
      }
  } while (next_permutation(aa.begin(), aa.end()));
  printf("%d %d\n", ans1, ans2);
  return 0;
}
