Hide

Every year, ambitious students head to The University of Chicago eager to pursue degrees in Computer Science. While knowledge itself is the greatest reward for a quarter of diligent scholarship, students still receive a grade for each course.

Professor X teaches several rigorous introductory computer science courses, all of which have some number of assignments and a final exam. Each assignment can receive a score between $0$ and $5$ points. The final exam is worth a total of $50$ points. All scores are given in whole numbers (i.e., students cannot receive fractions of points, only whole points).

When calculating a student’s final grade, the lowest assignment score is dropped. If there are multiple assignments with the same lowest score, only one is dropped (the one to drop can be selected arbitrarily). So, if the class has $M$ assignments, a student’s total score, $S_{total}$, is calculated as

$S_{total} = S_{1} + S_{2} + \ldots + S_{M-1} + S_{exam}$

where $S_{1} \ldots S_{M-1}$ are the scores of the assignments with the top $M-1$ scores. Note how the largest score a student could earn in the class is $5\cdot (M-1) + 50$ points.

$S_{total}$ is the total score but, since Professor X’s course is notoriously difficult, students’ actual grades are based on an adjusted scale based on the top performing student in the course. The adjusted percentage, $S_{adjusted}$, is calculated by treating the student with the highest $S_{total}$ as the the total possible points available in the course. So, if $MAX(S_{total})$ is the highest score for a given class, then $S_{adjusted}$ for a student is obtained as follows:

$S_{adjusted} = \frac{S_{total}}{MAX(S_{total})} \times 100$

Yes, at least one student each quarter will receive a $100$% in the course!

Professor X then takes $S_{adjusted}$ and converts it to an integer, which we will refer to as $S_{grade}$, because this is the value used to determine the student’s final grade. Professor X is tough but also generous: $S_{grade}$ is obtained by rounding $S_{adjusted}$ up to the nearest integer. So, if $S_{adjusted}$ is $89.0$, $S_{grade}$ will be $89$. However, if $S_{adjusted}$ is $89.00001$, then it will be rounded up and $S_{grade}$ will be $90$.

Once Professor X has $S_{grade}$, the student letter grade is assigned based on the following scale:

• A: $90 \leqslant S_{grade} \leqslant 100$

• B: $80 \leqslant S_{grade} < 90$

• C: $70 \leqslant S_{grade} < 80$

• D: $60 \leqslant S_{grade} < 70$

• F: $S_{grade} < 60$

In this problem, you will compute $S_{total}$, $S_{grade}$, and the letter grade for each student.

## Input

The input contains a list of students with their scores in the assignments and the exam. The input begins with a line containing two integers separated by a single space: the number of students $N$ ($1\leqslant N \leqslant 100$), and the number of assignments $M$ ($2\leqslant M \leqslant 20$).

This line is followed by $N$ lines, each representing a single student. Each such line contains a two-character string (the student’s initials) followed by $M+1$ integers, representing the scores on the $M$ assignments and on the exam. Every value is separated by a single space. The student’s initials are not guaranteed to be unique (i.e., there can be more than one student with the same initials).

## Output

The output is composed of $N$ lines, one per student. Each line contains the student’s initials followed by that student’s $S_{total}$, $S_{grade}$, and their letter grade. Each value is separated by a single space. The students must appear in the same order as they appear in the input.

Sample Input 1 Sample Output 1
3 11
AB 1 2 3 4 3 2 3 3 2 1 2 35
CD 0 0 1 3 2 2 0 1 1 2 3 25
EF 5 4 4 3 4 5 1 3 3 5 4 40

AB 60 75 C
CD 40 50 F
EF 80 100 A

Sample Input 2 Sample Output 2
3 6
MB 1 2 3 4 3 5 43
BD 0 0 1 2 3 1 25
CT 5 5 5 5 5 5 40

MB 60 93 A
BD 32 50 F
CT 65 100 A

Sample Input 3 Sample Output 3
5 8
BJ 5 3 2 2 5 0 1 2 32
EA 0 5 2 2 3 5 5 0 40
ZN 2 2 3 3 5 4 5 3 48
IZ 1 4 4 3 1 4 3 2 37
LD 0 5 2 3 5 2 4 5 42

BJ 52 72 C
EA 62 85 B
ZN 73 100 A
IZ 58 80 B
LD 68 94 A

Hide