# Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

# Super Sort

By rumman13 · Limits 1s, 1.0 GB

Given an array of numbers and a non-negative integer $K$ you have to sort the array in such a way so that the absolute difference between every adjacent element is no more than $K$.

For example if you have an array $A = [8, 7, 6, 9]$ and $K = 2$ then one possible solution will be $[8, 9, 7, 6]$ where $|8 - 9| = 1, |9 - 7| = 2, |7 - 6| = 1$ and the absolute difference between every adjacent elements are no more than $2$.

If there is many solution you have to print the lexicographically smallest answer. If there are no solution just print $\texttt{No Solution}$ .

## Input

Input will start with a positive integer $T$ ($0 < T \leq 150$) denoting the number of test cases.

Each test case will have two positive integer $N$ ($2 \leq N \leq 18$) denoting the number elements in the array and $K$ ($0 \leq K \leq 10^3$).

The next line will have $N$ space separated integers representing the array $A$ ($-10^3 \leq A_i \leq 10^3$).

## Output

For each test case if there is a solution print the lexicographically smallest sorted array. You have to print $N$ space separated integers without any leading or trailing spaces. If there are no solutions, print $\texttt{No Solution}$.

## Sample

InputOutput
2
2 2
3 1
2 1
1 3

1 3
No Solution


### Statistics

90% Solution Ratio

Lazy_ProgrammerEarliest, Nov '18

Lazy_ProgrammerFastest, 0.0s

Lazy_ProgrammerLightest, 131 kB

aNkanpy.pritomShortest, 206B