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 PYTHON):

Solution:


l = set([1, 2, 3, 4, 5, 6, 7])


def getCombs(l):
  if len(l) == 0:
    return []
  elif len(l) == 1:
    return [[], [l[0]]]  
  else:
    cmbs = getCombs(l[1:])
    newcms = []
    for c in cmbs:
      newcms.append(c[:])
      t = c[:]
      t.insert(0, l[0])
      newcms.append(t)

    return newcms     
          

def getCombs2(l, n):
  all = getCombs(l)
  newlis = []
  
  for i in all:
    if len(i) == n:
      newlis.append(i)  
  
  return newlis 

  

def getCombsOnPartitions(l, f, s, t):
  cs = getCombs2(l, f)
  
  accm  = []
  
  for c in cs:
    nl = list(set(l) - set(c))
    ncs = getCombs2(nl, s)
    for ca in ncs:
      nll = list(set(l) - set(c) - set(ca)) 
      accm.append([c, ca, nll])         
  
  return accm  
  
  
#ans = getCombsOnPartitions(['Anka','Chapay','Cleo','Troll','Dracul','Snowy ','Hexadecimal'], 5, 1, 1)
 

l= [(1, 7), (5, 5), (7, 2), (31, 9), (17, 50), (10, 13), (12, 1)]
l.sort(key = lambda x: x[1])


n = int(raw_input())

likings = []

for i in range(n):
  l = raw_input().split()
  likings.append([l[0], l[-1]])  


last_line = raw_input().split()
  
  
a = int(last_line[0])
b = int(last_line[1])
c = int(last_line[2])
 
lis = []

lis.append([(a, b, c/5), max(a, b, c/5) - min(a, b, c/5), (1, 1, 5)])
#210 200 36 = 174
lis.append([(a, b/2, c/4), max(a, b/2, c/4) - min(a, b/2, c/4), (1, 2, 4)])
#210 100 45 = 165
lis.append([(a, b/3, c/3), max(a, b/3, c/3) - min(a, b/3, c/3), (1, 3, 3)])
#210 66 60 = 150
lis.append([(a, b/4, c/2), max(a, b/4, c/2) - min(a, b/4, c/2), (1, 4, 2)])
#210 50 90 = 160
lis.append([(a, b/5, c), max(a, b/5, c) - min(a, b/5, c), (1, 5, 1)])
#210 40 180 = 170
lis.append([(a/2, b, c/4), max(a/2, b, c/4) - min(a/2, b, c/4), (2, 1, 4)])
#105 200 45 = 155
lis.append([(a/2, b/2, c/3), max(a/2, b/2, c/3) - min(a/2, b/2, c/3), (2, 2, 3)])
#105 100 60 = 45
lis.append([(a/2, b/3, c/2), max(a/2, b/3, c/2) - min(a/2, b/3, c/2), (2, 3, 2)])
#105 66 90 = 39
lis.append([(a/2, b/4, c), max(a/2, b/4, c) - min(a/2, b/4, c), (2, 4, 1)])
#105 50 180 = 130
lis.append([(a/3, b, c/3), max(a/3, b, c/3) - min(a/3, b, c/3), (3, 1, 3)])
#70 200 60 = 140
lis.append([(a/3, b/2, c/2), max(a/3, b/2, c/2) - min(a/3, b/2, c/2), (3, 2, 2)])
#70 100 90 = 30
lis.append([(a/3, b/3, c), max(a/3, b/3, c) - min(a/3, b/3, c), (3, 3, 1)])
#70 66 180 = 114
lis.append([(a/4, b, c/2), max(a/4, b, c/2) - min(a/4, b, c/2), (4, 1, 2)])
#52 200 90 = 148
lis.append([(a/4, b/2, c), max(a/4, b/2, c) - min(a/4, b/2, c), (4, 2, 1)])
#52 100 180 = 128
lis.append([(a/5, b, c), max(a/5, b, c) - min(a/5, b, c), (5, 1, 1)])
#42 200 180 = 158

lis.sort(key = lambda x: x[1])

same_diffs = [x for x in lis if x[1] == lis[0][1]]

  
#t is [[], [], []]  
def getMaxLiking(likings, t):

  count = 0
  for l in likings:
    if (l[0] in t[0]) and (l[1] in t[0]):
      count += 1
    elif (l[0] in t[1]) and (l[1] in t[1]):   
      count += 1
    elif (l[0] in t[2]) and (l[1] in t[2]):   
      count += 1

  return count

max_likings = -1  

for d in same_diffs:
  cms = getCombsOnPartitions(['Anka','Chapay','Cleo','Troll','Dracul','Snowy','Hexadecimal'], d[2][0], d[2][1], d[2][2])  
  #print cms  
  for c in cms:
    #print c
    ma = getMaxLiking(likings, c)   
    if ma > max_likings:
      max_likings = ma  

print str(same_diffs[0][1]), str(max_likings)
      
  
#getMaxLiking(likings, d[2])