URI Online Judge | 2365

# Brazilian Soccer' Big Bet

By Alexandre Davis, UFMG Brazil

Timelimit: 1

Many people will say that's just lucky, but Dilson have an incredible skill in win bets of soccer champioship. His last victory was won the computing bet of World Cup, including predicting the result of the Brazil x Germany and Spain x Netherlands match. Thinking in make himself a professional in bets, he ask you to create a program to compute the final rank of some bet.

In a bet, the competitors hit the scores of the soccer matches before the begin of the championship. After each match, they assign points to the competitors according with the following rules:

• 10 points - If the competitor hit the result (the team that won or lose) and the scores of each team.
• 7 points - If the competitor hit the result and the scores of one team.
• 5 points - If the competitor hit only the result
• 2 points - If the competitor hit the scores of one team
• 0 points - Otherwise

At end of the soccer championship, the competitor that scores more points is the champion. In this problem, you should output the final rank of the bet. The lexicographily order of the competitor name is the unique tiebreaker.

## Input

There are many test cases. The first line of each test case is composed by 2 integers P (1 ≤ P ≤ 10) and N (1 ≤ N ≤ 10) indicating, respectivelly, the number of the competitors in the bet and the number of the matches in the champioship. The next lines describe the competitor's hits.

The hit of i-th competitor are described in N+1 lines. The first line has only one Si, what is the name of competitor i. The N following lines describe the hits of each match j. These hits are described by Aj GAi,j Bj GBi,j, where Aj and Bj are strings indicating the teams that will confront in the j-th match, GAi,j and GBi,j ( 0 ≤ GAi,j , GBi,j ≤ 100 ) integer that represent, respectivelly, the scores that competitor i hopes that the teams Aj e Bj did in the match j. The competitors hit in the same order. Then, Aj and Bj are always the same for all competitors.

Lastly, there are N lines describing the real results of the matches. Each line has Aj RAj Bj RBj, where RAj e RBj ( 0 ≤ RAj , RBj ≤ 100 ) are integers that represent the scores of the teams Aj and Bj in this match.

The input ends with P = N = 0.

## Output

 Input Sample Output Sample 3 4 Dilson Barcelona 10 Santos 0 Atletico 9 Cruzeiro 2 Atletico 1 Barcelona 0 PontePreta 2 Cruzeiro 0 Henrique Barcelona 34 Santos 0 Atletico 0 Cruzeiro 1 Atletico 0 Barcelona 52 PontePreta 0 Cruzeiro 3 Filipe Barcelona 7 Santos 1 Atletico 0 Cruzeiro 1 Atletico 0 Barcelona 10 PontePreta 0 Cruzeiro 0 Barcelona 10 Santos 0 Atletico 9 Cruzeiro 2 Atletico 3 Barcelona 0 PontePreta 2 Cruzeiro 0 0 0 Dilson 37 Filipe 7 Henrique 7

Dilson scores 10 + 10 + 7 + 10 = 37 points, Henrique scores 7 + 0 + 0 + 0 = 7 points and Filipe scores 5 + 0 + 0 + 2 = 7 points, but Filipe is up in rank than Henrique because of the tiebreak (lexicographic order of his names)