#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000 * 1000 * 1000;
int likes[10][10];
vector<int> team[3];
vector<long long> monsters;
long long mindiff = INF, maxlike = -INF;
int countlikes() {
  int res = 0;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < (int)team[i].size(); j++) {
      for (int k = 0; k < (int)team[i].size(); k++) {
        int u = team[i][j], v = team[i][k];
        res += likes[u][v];
      }
    }
  }
  return res;
}
void go(int curr) {
  if (curr == 8) {
    for (int i = 0; i < 3; i++) {
      if ((int)team[i].size() == 0) return;
    }
    long long maxscore = -INF, minscore = INF;
    for (int i = 0; i < 3; i++) {
      maxscore = max(maxscore, monsters[i] / (long long)(int)team[i].size());
      minscore = min(minscore, monsters[i] / (long long)(int)team[i].size());
    }
    if (mindiff == maxscore - minscore) {
      maxlike = max(maxlike, (long long)countlikes());
    }
    if (mindiff > maxscore - minscore) {
      mindiff = maxscore - minscore;
      maxlike = countlikes();
    }
    return;
  }
  for (int i = 0; i < 3; i++) {
    team[i].push_back(curr);
    go(curr + 1);
    team[i].pop_back();
  }
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string h1, ss, h2;
  map<string, int> mm;
  int idx = 1;
  for (int i = 0; i < n; i++) {
    cin >> h1 >> ss >> h2;
    if (mm[h1] == 0) mm[h1] = idx++;
    if (mm[h2] == 0) mm[h2] = idx++;
    likes[mm[h1]][mm[h2]] = 1;
  }
  for (int i = 0; i < 3; i++) {
    long long v;
    cin >> v;
    monsters.push_back(v);
  }
  sort((monsters).begin(), (monsters).end());
  long long ans1 = INF, ans2 = -INF;
  do {
    go(1);
    ans1 = min(ans1, mindiff);
    ans2 = max(ans2, maxlike);
  } while (next_permutation((monsters).begin(), (monsters).end()));
  cout << ans1 << " " << ans2 << "\n";
  return 0;
}
