#C4690. Arrange Participants with Energy Threshold

    ID: 48256 Type: Default 1000ms 256MiB

Arrange Participants with Energy Threshold

Arrange Participants with Energy Threshold

In this problem, you are given multiple test cases. For each test case, you are provided with an integer (n) representing the number of participants, an integer (k) representing the minimum required difference between the energy levels of any two consecutive participants, and a list of (n) integers representing the energy levels. Your task is to determine if it is possible to arrange the participants in such a way that the absolute difference between the energy levels of any two consecutive participants is at least (k).

If it is possible, output "POSSIBLE" on one line and on the next line output the arranged (sorted) energy levels. Otherwise, output "IMPOSSIBLE".

inputFormat

The first line of input contains a single integer (T) representing the number of test cases.

For each test case, the first line contains two integers (n) and (k), where (n) is the number of participants and (k) is the minimum required difference between consecutive participants. The second line contains (n) space-separated integers representing the energy levels of the participants.

outputFormat

For each test case, if it is possible to arrange the participants such that the difference between any two consecutive energy levels is at least (k), print "POSSIBLE" on the first line, followed by a line containing the arranged energy levels separated by spaces. Otherwise, print "IMPOSSIBLE".## sample

3
3 2
4 1 7
4 3
10 4 1 7
2 6
5 11
POSSIBLE

1 4 7 POSSIBLE 1 4 7 10 POSSIBLE 5 11

</p>