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 <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/d9049b74dfcebaef5774f475b1e3ef4ed39cfc63.png" style="max-width: 100.0%;max-height: 100.0%;"/> 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.
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·10<sup class="upper-index">9</sup>), 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*.
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.
3
Troll likes Dracul
Dracul likes Anka
Snowy likes Hexadecimal
210 200 180
30 3
2
Anka likes Chapay
Chapay likes Anka
10000 50 50
1950 2
11
Snowy likes Dracul
Anka likes Dracul
Chapay likes Snowy
Hexadecimal likes Troll
Anka likes Cleo
Chapay likes Dracul
Anka likes Chapay
Snowy likes Troll
Anka likes Hexadecimal
Cleo likes Chapay
Troll likes Cleo
100 100 100
17 5
14
Chapay likes Cleo
Cleo likes Anka
Dracul likes Snowy
Snowy likes Cleo
Chapay likes Anka
Snowy likes Anka
Chapay likes Troll
Troll likes Anka
Anka likes Snowy
Chapay likes Dracul
Dracul likes Anka
Hexadecimal likes Chapay
Snowy likes Dracul
Cleo likes Dracul
15 15 15
2 6
4
Anka likes Cleo
Snowy likes Cleo
Anka likes Hexadecimal
Cleo likes Snowy
1 1 1
0 3
8
Snowy likes Anka
Hexadecimal likes Snowy
Troll likes Dracul
Hexadecimal likes Troll
Snowy likes Troll
Anka likes Snowy
Snowy likes Chapay
Anka likes Chapay
70 70 70
12 5
0
100 300 600
50 0
3
Chapay likes Hexadecimal
Anka likes Cleo
Troll likes Snowy
15 15000 90
2985 2
0
1 1 10000
1999 0
13
Cleo likes Hexadecimal
Cleo likes Snowy
Hexadecimal likes Anka
Anka likes Snowy
Troll likes Snowy
Chapay likes Hexadecimal
Hexadecimal likes Snowy
Snowy likes Chapay
Troll likes Cleo
Anka likes Hexadecimal
Hexadecimal likes Cleo
Chapay likes Dracul
Snowy likes Dracul
1000000000 2000000000 1000000000
166666666 6
12
Cleo likes Hexadecimal
Chapay likes Anka
Hexadecimal likes Cleo
Anka likes Snowy
Anka likes Cleo
Dracul likes Snowy
Anka likes Troll
Snowy likes Anka
Cleo likes Anka
Hexadecimal likes Troll
Hexadecimal likes Chapay
Snowy likes Troll
1000000000 1 2000000000
499999999 7
0
2000000000 2000000000 2000000000
333333334 0
2
Snowy likes Hexadecimal
Troll likes Dracul
2000000000 2000000000 2000000000
333333334 2
12
Snowy likes Chapay
Cleo likes Dracul
Hexadecimal likes Snowy
Hexadecimal likes Anka
Dracul likes Chapay
Cleo likes Troll
Dracul likes Snowy
Snowy likes Dracul
Troll likes Chapay
Dracul likes Anka
Chapay likes Hexadecimal
Troll likes Dracul
436364663 856574374 347564737
111742423 6
12
Anka likes Dracul
Dracul likes Troll
Cleo likes Troll
Snowy likes Hexadecimal
Hexadecimal likes Chapay
Cleo likes Dracul
Cleo likes Chapay
Hexadecimal likes Anka
Snowy likes Cleo
Hexadecimal likes Snowy
Cleo likes Snowy
Chapay likes Snowy
584329075 428752235 675234087
77788420 6
8
Anka likes Chapay
Dracul likes Snowy
Snowy likes Cleo
Cleo likes Anka
Cleo likes Troll
Hexadecimal likes Troll
Troll likes Cleo
Snowy likes Dracul
325432666 254352394 547360304
55277237 6
18
Snowy likes Troll
Chapay likes Hexadecimal
Cleo likes Snowy
Dracul likes Snowy
Snowy likes Chapay
Troll likes Cleo
Snowy likes Anka
Dracul likes Hexadecimal
Hexadecimal likes Anka
Anka likes Hexadecimal
Anka likes Chapay
Troll likes Anka
Anka likes Snowy
Anka likes Troll
Snowy likes Cleo
Hexadecimal likes Troll
Hexadecimal likes Dracul
Cleo likes Anka
20000 1000 20000
5666 8
6
Chapay likes Troll
Troll likes Cleo
Cleo likes Troll
Chapay likes Snowy
Anka likes Snowy
Troll likes Dracul
987499608 272739716 133573597
113301305 5
6
Anka likes Troll
Troll likes Chapay
Troll likes Hexadecimal
Hexadecimal likes Cleo
Snowy likes Hexadecimal
Chapay likes Troll
740076959 230477703 987799796
98788895 5
17
Cleo likes Dracul
Troll likes Cleo
Anka likes Chapay
Anka likes Troll
Chapay likes Snowy
Troll likes Snowy
Chapay likes Dracul
Hexadecimal likes Snowy
Dracul likes Snowy
Troll likes Hexadecimal
Hexadecimal likes Anka
Cleo likes Snowy
Hexadecimal likes Dracul
Snowy likes Chapay
Snowy likes Hexadecimal
Snowy likes Dracul
Dracul likes Troll
112909524 619275170 403563648
88872300 9
1
Hexadecimal likes Chapay
848189141 631955593 79523012
203206701 1
18
Anka likes Troll
Dracul likes Chapay
Hexadecimal likes Dracul
Chapay likes Dracul
Anka likes Hexadecimal
Snowy likes Cleo
Dracul likes Anka
Snowy likes Anka
Snowy likes Hexadecimal
Dracul likes Troll
Dracul likes Snowy
Hexadecimal likes Anka
Chapay likes Hexadecimal
Snowy likes Dracul
Cleo likes Snowy
Chapay likes Cleo
Anka likes Dracul
Troll likes Anka
838821770 712931449 361810998
124167182 8
18
Hexadecimal likes Chapay
Troll likes Dracul
Troll likes Snowy
Cleo likes Dracul
Chapay likes Snowy
Dracul likes Chapay
Cleo likes Snowy
Dracul likes Hexadecimal
Troll likes Anka
Anka likes Troll
Hexadecimal likes Dracul
Chapay likes Hexadecimal
Cleo likes Chapay
Anka likes Hexadecimal
Snowy likes Dracul
Chapay likes Troll
Anka likes Snowy
Dracul likes Cleo
240256138 922743697 38909902
191776022 10
0
477107314 230715335 261545417
43678104 0
16
Chapay likes Snowy
Hexadecimal likes Anka
Chapay likes Troll
Dracul likes Cleo
Troll likes Hexadecimal
Hexadecimal likes Dracul
Chapay likes Cleo
Snowy likes Cleo
Snowy likes Anka
Troll likes Chapay
Snowy likes Hexadecimal
Troll likes Snowy
Cleo likes Hexadecimal
Anka likes Snowy
Snowy likes Chapay
Anka likes Dracul
843382501 58524777 503038818
192994632 8
5
Troll likes Chapay
Anka likes Snowy
Anka likes Dracul
Chapay likes Anka
Snowy likes Troll
709201888 431802832 597079932
82638550 3
18
Cleo likes Snowy
Snowy likes Hexadecimal
Cleo likes Hexadecimal
Troll likes Dracul
Hexadecimal likes Snowy
Dracul likes Troll
Chapay likes Anka
Chapay likes Cleo
Troll likes Chapay
Hexadecimal likes Chapay
Anka likes Snowy
Troll likes Snowy
Dracul likes Snowy
Dracul likes Chapay
Chapay likes Troll
Cleo likes Troll
Hexadecimal likes Cleo
Anka likes Chapay
864225278 509037060 402199775
86975205 9
12
Cleo likes Hexadecimal
Troll likes Cleo
Anka likes Cleo
Hexadecimal likes Troll
Anka likes Snowy
Hexadecimal likes Anka
Troll likes Hexadecimal
Troll likes Anka
Dracul likes Cleo
Cleo likes Troll
Dracul likes Troll
Chapay likes Anka
762445890 377707484 324080158
92108551 6
21
Chapay likes Dracul
Snowy likes Chapay
Snowy likes Troll
Cleo likes Chapay
Cleo likes Troll
Chapay likes Cleo
Snowy likes Anka
Dracul likes Anka
Troll likes Snowy
Snowy likes Cleo
Chapay likes Hexadecimal
Cleo likes Anka
Cleo likes Snowy
Hexadecimal likes Cleo
Hexadecimal likes Snowy
Hexadecimal likes Anka
Hexadecimal likes Troll
Anka likes Snowy
Dracul likes Troll
Chapay likes Anka
Snowy likes Hexadecimal
482557397 502108264 750230216
9775434 8
6
Troll likes Chapay
Hexadecimal likes Snowy
Cleo likes Dracul
Cleo likes Anka
Chapay likes Anka
Anka likes Chapay
758376921 432619768 578580897
72980564 5
5
Chapay likes Cleo
Anka likes Hexadecimal
Anka likes Chapay
Cleo likes Troll
Anka likes Cleo
299076810 225593528 36830738
62861532 3
13
Anka likes Cleo
Cleo likes Troll
Chapay likes Cleo
Snowy likes Troll
Chapay likes Anka
Chapay likes Snowy
Snowy likes Chapay
Anka likes Snowy
Snowy likes Dracul
Cleo likes Hexadecimal
Dracul likes Chapay
Anka likes Hexadecimal
Snowy likes Cleo
554338888 280967932 682619964
96188303 7
17
Hexadecimal likes Chapay
Chapay likes Snowy
Chapay likes Troll
Anka likes Hexadecimal
Cleo likes Troll
Snowy likes Cleo
Cleo likes Anka
Cleo likes Hexadecimal
Anka likes Snowy
Chapay likes Hexadecimal
Anka likes Cleo
Dracul likes Snowy
Chapay likes Anka
Troll likes Hexadecimal
Troll likes Anka
Anka likes Dracul
Hexadecimal likes Anka
828886798 548024213 166661324
107350782 9
2
Troll likes Cleo
Anka likes Cleo
14344913 559182022 405430772
172049094 2
22
Cleo likes Snowy
Cleo likes Troll
Chapay likes Dracul
Snowy likes Troll
Dracul likes Chapay
Dracul likes Snowy
Chapay likes Cleo
Snowy likes Chapay
Dracul likes Troll
Anka likes Hexadecimal
Snowy likes Anka
Hexadecimal likes Cleo
Hexadecimal likes Troll
Dracul likes Anka
Cleo likes Hexadecimal
Hexadecimal likes Dracul
Chapay likes Troll
Chapay likes Hexadecimal
Anka likes Snowy
Troll likes Hexadecimal
Snowy likes Hexadecimal
Anka likes Chapay
458053183 602148195 994999698
102639975 9
5
Troll likes Dracul
Anka likes Chapay
Cleo likes Anka
Chapay likes Cleo
Snowy likes Hexadecimal
222 400 400
89 5
0
2000000000 2000000000 1
666666665 0
0
1200000000 1200000000 1200000000
200000000 0
0
1 2000000000 2000000000
666666665 0
#!/usr/bin/env python3

import itertools

heroes = ["Anka", "Chapay", "Cleo", "Troll", "Dracul", "Snowy", "Hexadecimal"]

n = int(input())
edges = []
for i in range(n):
  p,likes,q = input().split()
  edges.append((heroes.index(p), heroes.index(q)))
boss_xp = list(map(int, input().split()))

min_difference = float('inf')
max_liking = float('-inf')
for assignment in itertools.product(range(3), repeat=7):
  assignment_heroes = [[hero for (hero, boss) in enumerate(assignment) if (boss == i)] for i in range(3)]
  if any(len(attackers) == 0 for attackers in assignment_heroes):
    # Some bosses are not attacked at all
    continue

  xp_division = [xp / len(attackers) for (xp, attackers) in zip(boss_xp, assignment_heroes)]
  difference = max(xp_division) - min(xp_division)
  if (difference < min_difference):
    min_difference = difference
    max_liking = sum(len([(p,q) for (p,q) in edges if (p in attackers) and (q in attackers)]) for attackers in assignment_heroes)
  elif (difference == min_difference):
    liking = sum(len([(p,q) for (p,q) in edges if (p in attackers) and (q in attackers)]) for attackers in assignment_heroes)
    max_liking = max(max_liking, liking)

print("%d %d" % (min_difference, max_liking))