Problem: The year of 2012 is coming...

According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the human world. But seven brave heroes have already gathered on the top of a mountain Arreat to protect us mere mortals from the effect of this terrible evil.

The seven great heroes are: amazon Anka, barbarian Chapay, sorceress Cleo, druid Troll, necromancer Dracul, paladin Snowy and a professional hit girl Hexadecimal. Heroes already know how much experience will be given for each of the three megabosses: a for Mephisto, b for Diablo and c for Baal.

Here's the problem: heroes are as much as seven and megabosses are only three! Then our heroes decided to split into three teams, where each team will go to destroy their own megaboss. Each team member will receive a <image> of experience, rounded down, where x will be the amount of experience for the killed megaboss and y — the number of people in the team.

Heroes do not want to hurt each other's feelings, so they want to split into teams so that the difference between the hero who received the maximum number of experience and the hero who received the minimum number of experience were minimal. Since there can be several divisions into teams, then you need to find the one in which the total amount of liking in teams were maximum.

It is known that some heroes like others. But if hero p likes hero q, this does not mean that the hero q likes hero p. No hero likes himself.

The total amount of liking in teams is the amount of ordered pairs (p, q), such that heroes p and q are in the same group, and hero p likes hero q (but it is not important if hero q likes hero p). In case of heroes p and q likes each other and they are in the same group, this pair should be counted twice, as (p, q) and (q, p).

A team can consist even of a single hero, but it is important that every megaboss was destroyed. All heroes must be involved in the campaign against evil. None of the heroes can be in more than one team.

It is guaranteed that every hero is able to destroy any megaboss alone.

Input

The first line contains a single non-negative integer n (0 ≤ n ≤ 42) — amount of liking between the heroes. Next n lines describe liking in the form "p likes q", meaning that the hero p likes the hero q (p ≠  q). Every liking is described in the input exactly once, no hero likes himself.

In the last line are given three integers a, b and c (1 ≤ a, b, c ≤ 2·109), separated by spaces: the experience for Mephisto, the experience for Diablo and experience for Baal.

In all the pretests, except for examples from the statement, the following condition is satisfied: a = b = c.

Output

Print two integers — the minimal difference in the experience between two heroes who will receive the maximum and minimum number of experience points, and the maximal total amount of liking in teams (the number of friendships between heroes that end up in one team).

When calculating the second answer, the team division should satisfy the difference-minimizing contraint. I.e. primary you should minimize the difference in the experience and secondary you should maximize the total amount of liking.

Examples

Input

3
Troll likes Dracul
Dracul likes Anka
Snowy likes Hexadecimal
210 200 180


Output

30 3


Input

2
Anka likes Chapay
Chapay likes Anka
10000 50 50


Output

1950 2

Note

A note to first example: it the first team should be Dracul, Troll and Anka, in the second one Hexadecimal and Snowy, and in the third Cleo и Chapay.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
inline void DoNothing() {}
template <typename T>
inline T Abs(const T a) {
  return a < 0 ? -a : a;
}
template <typename T>
inline T Min(const T a, const T b) {
  return a < b ? a : b;
}
template <typename T>
inline T Max(const T a, const T b) {
  return a > b ? a : b;
}
static const long double eps = 1.0e-07;
template <typename T>
inline T IsEqual(const T a, const T b) {
  return Abs(a - b) < eps;
}
template <typename T>
inline T IsGreater(const T a, const T b) {
  return a > b + eps;
}
template <typename T>
inline T IsLess(const T a, const T b) {
  return a + eps < b;
}
template <typename T>
inline void Print(const T& val) {
  std::cout << val << ' ';
}
template <typename T>
inline std::string ToStr(const T& val) {
  std::ostringstream ostr;
  ostr << val;
  return ostr.str();
}
template <typename T>
inline bool FromStr(const std::string& str, T& val) {
  std::istringstream istr(str);
  istr >> val;
  return !!istr;
}
struct Rand {
  unsigned long z_, w_;
  unsigned long get32() {
    z_ = 36969 * (z_ & 65535) + (z_ >> 16);
    w_ = 18000 * (w_ & 65535) + (w_ >> 16);
    return (z_ << 16) + (w_ & 65535);
  }
  void Reset() {
    z_ = 1;
    w_ = 1;
  }
  Rand() { Reset(); }
};
template <typename T>
inline std::vector<std::vector<T> > CreateVector2d(const size_t rowCnt,
                                                   const size_t colCnt) {
  return std::vector<std::vector<T> >(rowCnt, std::vector<T>(colCnt));
}
void Prepare();
class StopWatchEx {
 public:
  StopWatchEx();
  ~StopWatchEx();

 private:
  struct Data;
  Data* pData;
};
inline bool EstimateSet(const std::vector<size_t>& distribution,
                        const std::vector<std::vector<size_t> >& links,
                        const std::vector<size_t>& expCount,
                        const size_t diffExpMin, size_t& diffExp,
                        size_t& sympCnt) {
  const size_t heroCnt = distribution.size();
  const size_t monstrCnt = expCount.size();
  std::vector<size_t> teamSize(monstrCnt);
  for (size_t i = 0; i < distribution.size(); i++) {
    teamSize[distribution[i]] += 1;
  }
  std::vector<size_t> expGained(monstrCnt);
  for (size_t i = 0; i < monstrCnt; i++) {
    if (teamSize[i] == 0) return false;
    expGained[i] = expCount[i] / teamSize[i];
  }
  std::sort(expGained.begin(), expGained.end());
  diffExp = expGained[monstrCnt - 1] - expGained[0];
  if (diffExp > diffExpMin) {
    return false;
  }
  sympCnt = 0;
  for (size_t i = 0; i < heroCnt; i++) {
    for (size_t j = 0; j < heroCnt; j++) {
      if (distribution[i] == distribution[j] && links[i][j] != 0) {
        sympCnt++;
      }
    }
  }
  return true;
}
std::vector<size_t> ConvertToVector(const size_t n, const size_t id) {
  std::vector<size_t> dist(n);
  size_t r = id;
  for (size_t i = 0; i < n; i++) {
    dist[n - i - 1] = r % 3;
    r /= 3;
  }
  return dist;
}
bool Solve(bool bCheckInputStream = false) {
  size_t nLinks;
  std::cin >> nLinks;
  if (bCheckInputStream && !std::cin) {
    return false;
  }
  StopWatchEx _sw;
  static const std::string Names[] = {"Anka",   "Chapay", "Cleo",       "Troll",
                                      "Dracul", "Snowy",  "Hexadecimal"};
  const size_t n = sizeof(Names) / sizeof(Names[0]);
  std::map<std::string, size_t> namesToIdx;
  for (size_t i = 0; i < n; i++) {
    namesToIdx[Names[i]] = i;
  }
  std::vector<std::vector<size_t> > links(n, std::vector<size_t>(n, 0));
  for (size_t i = 0; i < nLinks; i++) {
    std::string name1, name2;
    std::string dummy;
    std::cin >> name1 >> dummy >> name2;
    links[namesToIdx[name1]][namesToIdx[name2]] = 1;
  }
  std::vector<size_t> expCount(3);
  for (size_t i = 0; i < expCount.size(); i++) {
    std::cin >> expCount[i];
  }
  size_t diffExpMin = INT_MAX;
  size_t sympCntMax = 0;
  size_t idMax = 1;
  for (size_t i = 0; i < n; i++) {
    idMax *= 3;
  }
  for (size_t id = 0; id < idMax; id++) {
    const std::vector<size_t> dist = ConvertToVector(n, id);
    size_t diffExp = 0;
    size_t sympCnt = 0;
    if (EstimateSet(dist, links, expCount, diffExpMin, diffExp, sympCnt)) {
      if (diffExp < diffExpMin) {
        diffExpMin = diffExp;
        sympCntMax = sympCnt;
      } else {
        sympCntMax = std::max(sympCnt, sympCntMax);
      }
    }
  }
  std::cout << diffExpMin << ' ' << sympCntMax << std::endl;
  return true;
}
int main() {
  Prepare();
  Solve();
}
struct StopWatchEx::Data {};
StopWatchEx::StopWatchEx() {}
StopWatchEx::~StopWatchEx() {}
void Prepare() {}