A school picks its ten best teachers out of n teachers (n≤50) by a secret ballot among the students.
The teachers are numbered continuously starting at 1, and every number is written with two characters: 01, 02, 03 and so on.
One ballot lists the numbers of ten selected teachers. The position a number sits in is the place that ballot gives the teacher. A place may be left empty, and an empty place is written as 00. A ballot is discarded when it holds a number outside the range 01 to n, or when the same teacher number appears twice or more. The empty marker 00 may repeat as often as it likes and never discards a ballot.
Each place carries a score.
| Place | First | Second | Third | Fourth | Fifth | Sixth | Seventh | Eighth | Ninth | Tenth |
|---|---|---|---|---|---|---|---|---|---|---|
| Score | 15 | 12 | 9 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
The vote count of a teacher is the number of accepted ballots that write that teacher into a place other than an empty one. Sort the teachers by total score, from high to low. Two teachers on the same score are ordered by vote count, the larger one first. When the score and the vote count are both equal, the smaller teacher number comes first.
The first line holds two integers n and m separated by a space: the number of teachers and the number of ballots.
Each of the next n lines describes one teacher as a number, a name, and a department, separated by single spaces. The teacher lines may arrive in any order, and no name or department contains a space. Names are at most 15 characters long and departments at most 37.
Each of the next m lines holds one ballot, a string of exactly 20 characters made of ten two-digit numbers.
The last line is -1.
Print the first min(n,10) teachers of the sorted order, one per line. Each line joins the following fields with no separator between them.
A field shorter than its width is padded with spaces, so every printed line is 132 characters long.