Mr. Chips uses a simple grading scheme that can be computed automatically. Write a program that reads his students' test grades, bonus points, and attendance records, computes each student's grade, and outputs the class's average grade point.
Mr. Chips grades as follows. Every test is out of 100 points, and every test grade is an integer between 0 and 100. If more than 2 tests have been given, he drops each student's lowest test grade before computing that student's average. After computing the student averages, he computes the overall class mean and standard deviation (sd).
The letter-grade cutoffs are based on the class mean and sd:
For every two bonus points a student has accrued, Mr. Chips raises that student's computed average by 3 percentage points. So a student with 1 bonus point gets no boost, a student with 4 or 5 bonus points gets +6 points, and so on (the boost is $\lfloor bonus / 2 \rfloor \times 3$). Bonus boosts are applied to the averages after the grade cutoffs have been determined.
Finally, attendance adjusts the letter grade. For every 4 absences a student loses one letter grade (A→B, B→C, C→D, D→F); for example, 9 absences cost two letter grades. A student can never fall below F. A student with perfect attendance (0 absences) gains one letter grade, but can never rise above A.
Throughout his computations, Mr. Chips always rounds results to the nearest tenth.
In summary, for each class Mr. Chips drops each student's lowest test grade if more than 2 tests were given, computes each student's average, computes the class mean and sd, applies the bonus boosts to the averages, determines each student's letter grade from the cutoffs, and finally adjusts the letter grades for attendance.
The average grade point of a class uses 4 points for each A, 3 for each B, 2 for each C, 1 for each D, and 0 for each F. The class's total points are summed and divided by the number of students (always at least 2).
The standard deviation sd of a list of numbers $x_1, \dots, x_n$ is
$$sd = \sqrt{\frac{1}{n}\sum_{i=1}^{n}\left(x_i - \bar{x}\right)^2}$$
where $\bar{x}$ is the mean of the list. If the computed standard deviation is less than 1, Mr. Chips uses 1 in its place for the grade calculation.
Worked example: suppose Mr. Chips has 5 students and has given 3 tests. The table below shows each student's test scores, bonus points, and absences, together with the computed average (lowest test dropped), the adjusted average (with bonus), the unadjusted grade, and the adjusted grade (with attendance). The mean and sd used for the cutoffs are 69.0 and 20.1, so, for instance, an unadjusted B requires an average $\ge 69.0$ and $< 89.1$.
| T1 | T2 | T3 | Bns | Abst | Avg | AdjAvg | Grade | AdjGrd |
|---|---|---|---|---|---|---|---|---|
| 100 | 100 | 80 | 3 | 2 | 100.0 | 103.0 | A | A |
| 80 | 80 | 80 | 0 | 5 | 80.0 | 80.0 | B | C |
| 60 | 20 | 70 | 5 | 3 | 65.0 | 71.0 | B | B |
| 40 | 40 | 40 | 5 | 0 | 40.0 | 46.0 | D | C |
| 100 | 20 | 20 | 1 | 9 | 60.0 | 60.0 | C | F |
The average grade point for this class is 2.2.
The first line contains an integer $N$ ($1 \le N \le 10$): the number of classes.
Each class is described as follows. The first line contains two integers $S$ and $T$, where $S$ is the number of students ($1 < S < 31$) and $T$ is the number of tests taken ($1 < T < 11$). The next $S$ lines each describe one student: first the student's $T$ test scores (integers between 0 and 100 inclusive), then the student's bonus points, then the student's number of absences.
Output one line for each class: that class's average grade point, rounded to the nearest tenth.