CF2189A.Table with Numbers

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Table with Numbers

Peter drew a table of size h×lh \times l, filled with zeros. We will number its rows from 11 to hh from top to bottom, and columns from 11 to ll from left to right. Ned came up with an array of numbers a1,a2,,ana_1, a_2, \ldots, a_n and wanted to modify the table.

Ned can choose 2kn2k \leq n numbers from his array and split them into kk pairs. After that, for each resulting pair x,yx, y, he takes the cell located in row xx and column yy, and adds 11 to the number in that cell. If such a cell does not exist, then this pair does nothing to the table.

Peter supported Ned's initiative and asked him to maximize the sum of the numbers in the table. Help Ned understand what the maximum sum he can achieve is.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t5001 \le t \le 500). The description of the test cases follows.

The first line of each test case contains three integers nn, hh, and ll (2n1002 \le n \le 100, 1h,l10001 \le h, l \le 1000) — the size of the array, the height of the table, and the width of the table, respectively.

The second line of each test case contains nn numbers a1a_1, a2a_2, \ldots, ana_n (1ai10001 \le a_i \le 1000) — the array itself.

Output

For each test case, output the maximum possible sum of the numbers in the table.

Note

In the first test case, Ned can take the pair (1,1)(1, 1) and add 11 to the number located in row 11 and column 11.

In the second test case, Ned can take the numbers 1,2,2,21, 2, 2, 2 and pair them as follows: (1,2),(2,2)(1, 2), (2, 2). Then, in two cells of the table, there will be a 11, and the sum will be equal to 22. It can be shown that it is not possible to achieve a higher sum.

In the fifth test case, the only pair that Ned can take is (5,5)(5, 5). Since such a cell does not exist in the table, the sum of the numbers in the table cannot exceed 00.

In the seventh test case, Ned can pair the numbers like this: (1,1),(1,1)(1, 1), (1, 1). Then the only cell in the table will contain the number 22, and the sum will also be 22. It can be shown that it is not possible to achieve a higher sum.

Samples

7
2 1 1
1 1
5 2 2
1 2 2 3 2
8 4 2
7 2 2 2 3 4 4 2
7 3 6
10 4 1 3 5 4 6
2 4 4
5 5
7 6 3
10 4 1 3 5 4 6
4 1 1
1 1 1 1
1
2
3
2
0
2
2

在线编程 IDE

建议全屏模式获得最佳体验