#include <bits/stdc++.h>
using namespace std;
int n, m;
map<string, int> mp;
int r[10][10];
bool use[10];
int pans = 0;
void init() {
  memset(use, 0, sizeof(use));
  pans = 0;
}
int arr[10];
int ni, nj, nk;
void gao(int id, int ni, int nj, int nk) {
  if (id == 7) {
    int ans = 0;
    for (int i = 0; i < ni; i++) {
      for (int j = 0; j < ni; j++) {
        if (r[arr[i]][arr[j]]) ans++;
      }
    }
    for (int i = ni; i < ni + nj; i++)
      for (int j = ni; j < ni + nj; j++) {
        if (r[arr[i]][arr[j]]) ans++;
      }
    for (int i = ni + nj; i < ni + nj + nk; i++)
      for (int j = ni + nj; j < ni + nj + nk; j++) {
        if (r[arr[i]][arr[j]]) ans++;
      }
    if (ans > pans) pans = ans;
    return;
  }
  for (int i = 0; i < 7; i++) {
    if (!use[i]) {
      use[i] = 1;
      arr[id] = i;
      gao(id + 1, ni, nj, nk);
      use[i] = 0;
    }
  }
}
vector<vector<int> > ans;
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    mp.clear();
    int index = 0;
    memset(r, 0, sizeof(r));
    ans.clear();
    string x, y, love;
    int a, b, c;
    for (int i = 0; i < n; i++) {
      cin >> x >> love >> y;
      if (mp.find(x) == mp.end()) mp[x] = index++;
      if (mp.find(y) == mp.end()) mp[y] = index++;
      r[mp[x]][mp[y]] = 1;
    }
    scanf("%d%d%d", &a, &b, &c);
    int d = -1, tmpma = -1;
    for (int i = 1; i < 7; i++)
      for (int j = 1; j < 7; j++) {
        int k = 7 - i - j;
        if (k <= 0) continue;
        int da = (a / i), db = (b / j), dc = (c / k);
        int ma = max(da, max(db, dc)), mi = min(da, min(db, dc));
        if (d == -1 || ma - mi < d) {
          d = ma - mi;
          ans.clear();
          vector<int> t;
          t.push_back(i);
          t.push_back(j);
          t.push_back(k);
          ans.push_back(t);
        } else if (ma - mi == d) {
          vector<int> t;
          t.push_back(i);
          t.push_back(j);
          t.push_back(k);
          ans.push_back(t);
        }
      }
    init();
    for (int i = 0; i < ans.size(); i++) {
      gao(0, ans[i][0], ans[i][1], ans[i][2]);
    }
    cout << d << " " << pans << endl;
  }
  return 0;
}
