New update is available. Click here to update.

# Array And A Mathematics Equation

Last Updated: 23 Feb, 2021
Difficulty: Moderate

## PROBLEM STATEMENT

#### For Example :

``````Let ‘ARR[]’ = [1, 2, -1] and ‘X’ = 1, ’Y’ =2 and ‘Z’ = 1. Then, for each element at index ‘i’ in the ‘ARR’:
For ‘i’ = 0, ‘ARR[0]’ = 1 and after applying the equation as ‘1 * (1 * 1) + 2 * (1) + 1‘ ‘ARR[0]’ becomes 4.
For ‘i’ = 1, ‘ARR[1]’ = 2 and after applying the equation as ‘1 * (2 * 2) + 2 * (2) + 1‘ ‘ARR[1]’ becomes 9 .
For ‘i’ = 2, ‘ARR[2]’ = -1 and after applying the equation as ‘1 * (-1 * -1) + 2 * (-1) + 1‘ ‘ARR[2]’ becomes 0.
So, ‘ARR’ after modification [4, 9, 0]. The final ‘ARR’ after sorting is [0, 4, 9].
``````

#### As Ninja is weak with Maths, he asks you for help. Can you help Ninja sort the given ‘ARR’ after applying the quadratic equation to each element?

##### Input Format :
``````The first line of input contains an integer ‘T’ which denotes the number of test cases to be run. Then the test cases follow.

The first line of each test case contains four single space-separated integers ‘N’, ’X’, ’Y’, and ‘Z’ representing the number of elements in the array/list ‘ARR’ and three coefficients of a quadratic equation.

The next line of each test case contains ‘N’ single space-separated integers denoting the elements of  ‘ARR’.
``````
##### Output Format :
``````For each test case, print the sorted ‘ARR’ after applying the given equation.

Print the output of each test case in a separate line.
``````

#### Note :

``````You do not need to print anything. It has already been taken care of. Just implement the given function.
``````
##### Constraints :
``````1 <= ‘T’ <= 100
1 <= ‘N’ <= 5000
-10^5 <= ‘X’, ‘Y’ and ‘Z’ <= 10^5
-10^5 <= ‘ARR[i]’ <= 10^5

Where 'ARR[i]' denotes the 'ith' element of the array.

Time Limit: 1 sec
``````