#C8099. Best Programmer

    ID: 52043 Type: Default 1000ms 256MiB

Best Programmer

Best Programmer

You are given the productivity records of p programmers over d days. Each programmer has a productivity value for each day. You are also given q queries. Each query contains two integers l and r, which represent a range of days. For each query, compute the average daily increase in productivity for each programmer over the period from day l to day r using the formula:

$$\text{Average Increase} = \frac{\text{progress}[r] - \text{progress}[l]}{r - l + 1} $$

Note that the production records are provided as 1-indexed when considering the days (i.e. the first day is index 1), but you may need to convert indexes appropriately in your implementation.

Output the 1-indexed identifier of the programmer with the highest average daily increase. In the event of a tie, output the programmer with the smallest index.

Note: Input will be given from standard input and output should be written to standard output.

inputFormat

The first line contains three integers p, d, and q separated by spaces:

  • p: the number of programmers.
  • d: the number of days.
  • q: the number of queries.

The next p lines each contain d integers. The ith line represents the productivity values of the ith programmer for each day.

The following q lines each contain two integers l and r indicating the range of days (inclusive) for the query.

outputFormat

For each query, print the 1-indexed identifier of the programmer who has the highest average daily increase in productivity over the given range. Each result should be printed on a new line.

## sample
3 5 2
5 6 7 8 9
3 3 3 3 3
10 20 30 40 50
1 3
2 5
3

3

</p>