#K5371. Beautify Flower Beds

    ID: 29592 Type: Default 1000ms 256MiB

Beautify Flower Beds

Beautify Flower Beds

You are given several test cases. For each test case, you have a rectangular garden represented as a grid with N rows and M columns. Each cell contains an integer representing the type of flower planted.

In addition, each test case begins with three integers N, M, and K. Although K is provided, it is not used in the current task. Your goal is to rearrange the flowers in any order you wish (rearrangement is free; you can place the same flower types together arbitrarily) to obtain maximum beauty.

The beauty of a flower bed is defined as the maximum number of occurrences of any single flower type, i.e., $$\text{beauty} = \max_{x} \;\; count(x)$$ where $$count(x)$$ is the number of cells with flower type x.

Your task is to compute the maximum beauty for each test case.

inputFormat

The input begins with a single integer T (T ≥ 1), representing the number of test cases. Each test case is described as follows:

  1. A line with three integers: N M K, where N is the number of rows in the grid, M is the number of columns, and K is an extra parameter (unused in the computation).
  2. Then follow N lines, each containing M integers. Each integer represents a flower type.

outputFormat

For each test case, output one integer on a new line — the maximum beauty of the flower bed, i.e. the highest frequency of any flower type after rearrangement.

## sample
3
3 3 3
1 2 3
3 2 1
1 3 2
4 4 4
1 2 1 2
2 1 2 1
3 4 3 4
4 3 4 3
5 5 5
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5
3

4 5

</p>