Sacrifice#11805

Sacrifice

1 second
256 megabytes
Medium

Given an array of length and parameters and , you can perform any number of swaps in the array. After the operations (possibly zero operations), we cycle the array (repeat it an infinite number of times). Among all the arrays that you can achieve, output one that maximizes the value below:

f = \max(a_m + a_{m+1} + \dotsb + a_{m+k-1})

For example, for a = [1,2,3,4], we consider a_5 = 1 and a_6 = 2, and so on.

Input

The first line contains a single integer (1 \le t \le 10) -- the number of test cases.

The first line of each test case contains three integers , , (1 \le m \le n \le 10^5, 1 \le k \le 10^9).

The second line of each test case contains space-separated integers a_1, a_2, \dotsc, a_n (1 \le a_1, a_2, \dotsc, a_n \le 10^9) -- the array .

It is guaranteed that the sum of for all tests does not exceed 2 \cdot 10^5.

Output

Output any valid permutation of that maximizes the value.

Note

In the first test case, one of the optimal sums will consist of the following bold numbers [3,[**4,9,5**],1], which gives \max(f) = 18.

In the second test case, one of the optimal sums will consist of the following red numbers:[**2_{(2)},1_{(3)},3_{(1)}**], which gives \max(f) = 6.

In the third test case, one of the optimal sums will consist of the following red numbers (according to the cyclic pattern):

  1. [6,3,2,**10**], total sum , and we summed element so far.

  2. [**6,3,2,10**], total sum , and we summed elements so far.

  3. [**6,3,2,10**], total sum , and we summed elements so far.

  4. [**6,3,2,10**], total sum , and we summed elements so far.

  5. [**6,3,2,10**], total sum , and we summed elements so far.

This gives \max(f)=94.

Scoring

  1. (5 points): m+k-1 \le n

  2. (10 points): 1 \le k \le n \le 10

  3. (10 points): 1 \le k \le n \le 500

  4. (15 points): m=1

  5. (20 points): a_i \le 2

  6. (40 points): no additional constraints.

Examples

Example 1

Loading
Loading