actionPoints = {'S': 10, 'Q': 5, 'A': 7, 'L': -8, 'F': 4, 'D': -5, 'E': -10}
for oneWeek in range(7):
participants = int(input())
nameDir = {}
actDir = {}
for p in range(participants):
uniqueID, name1, name2 = input().split()
nameDir[uniqueID] = name1 + ' ' + name2
actDir[uniqueID] = 0
actions = int(input())
for a in range(actions):
uniqueID, action = input().split()
total = actionPoints.get(action, 0)
actDir[uniqueID] += total
for i, d in actDir.items():
if d == max(actDir.values()):
keepH = i
elif d == min(actDir.values()):
keepL = i
print(max(actDir.values()), nameDir.get(keepH))
print(min(actDir.values()), nameDir.get(keepL))
Comments