#C617. Lexicographically Largest Strictly Increasing Array

    ID: 49900 Type: Default 1000ms 256MiB

Lexicographically Largest Strictly Increasing Array

Lexicographically Largest Strictly Increasing Array

You are given multiple test cases. Each test case contains an integer array A of length N and an integer M representing the number of operations allowed. In one operation, you append the number 1000 to the end of the array.

Your task is to form a new array B by performing exactly M operations. However, this can only be done if the original array A is strictly increasing, i.e. for every index i (where 0 ≤ i < N - 1), the condition A[i] < A[i+1] holds. If A is not strictly increasing, output IMPOSSIBLE.

If it is possible, output the resulting array B which is formed by taking the original array A and appending exactly M numbers of 1000 at the end. Elements in the output should be separated by a single space. Each test case’s result should be printed on its own line.

Note: The lexicographically largest condition is achieved by appending the maximum allowed value (i.e. 1000) in each operation.

inputFormat

The first line of the input contains a single integer T, the number of test cases. For each test case:

  • The first line contains two integers N and M, where N is the number of elements in the array A, and M is the number of operations.
  • If N > 0, the next line contains N integers representing the array A, separated by spaces. If N is 0, this line is omitted.

All input is read from standard input (stdin).

outputFormat

For each test case, print a line with the resulting array B as space-separated integers if the operation can be performed. Otherwise, print IMPOSSIBLE if the original array is not strictly increasing. All output should be written to standard output (stdout).

## sample
3
4 1
2 3 4 5
5 2
4 5 6 7 8
0 3
2 3 4 5 1000

4 5 6 7 8 1000 1000 1000 1000 1000

</p>