#C7630. Best Average Performance

    ID: 51523 Type: Default 1000ms 256MiB

Best Average Performance

Best Average Performance

Sasha is the leader of her school's robotics club. In preparation for an upcoming competition, she needs to verify that all the components of the robot work correctly. Each component is tested multiple times and its performance scores are recorded. For each query, given a part number and a range of tests indexed from \(X_i\) to \(Y_i\), you are required to compute the average performance score for that part. The average is computed as follows:

\(\text{average} = \frac{\sum_{i=X_i}^{Y_i} score_i}{Y_i - X_i + 1}\)

All averages must be printed formatted to 2 decimal places.

inputFormat

The input begins with an integer \(T\) representing the number of test cases. For each test case, the input is structured as follows:

  • The first line contains two integers \(P\) and \(M\), where \(P\) is the number of parts and \(M\) is the number of tests conducted per part.
  • Then \(P\) lines follow, each containing \(M\) integers representing the performance scores for that part.
  • The next line contains an integer \(Q\), the number of queries.
  • Then \(Q\) lines follow, each containing three integers: the part number (1-indexed), the starting test index (1-indexed), and the ending test index (inclusive, 1-indexed).

outputFormat

For each query, output the average performance score for the specified part and test range, formatted to 2 decimal places. Each answer should be printed on a new line in the order the queries appear in the input.

## sample
3
3 5
5 4 3 2 1
1 2 3 4 5
2 2 2 2 2
3
1 1 3
2 2 5
3 1 5
2 3
10 20 30
5 5 5
2
1 2 3
2 1 2
1 4
7 8 9 10
1
1 1 4
4.00

3.50 2.00 25.00 5.00 8.50

</p>