Given a sorted integer array of size **N**, and 3 integers **A**, **B** and **C. **The task is to find and print a new array in sorted order(increasing) where A_{i}new=**A***A_{i}old*A_{i}old+**B***A_{i}old+**C.**

**Input:**

The first line of input contains **T** denoting the number of test cases.The first line of each test case contains three integers **A, B, and C, **as described above. The second line of each test case contains a single integer **N**, the size of the input array. The third line of each test case contains N-space separated integers, denoting the array.

**Output:**

For each test case output, a single line containing N-space separated integers, the elements of the new array in sorted order.

**Constraints:**

1 <= T <= 1000

-10^{5 }<= A,B,C <= 10^{5}

1 <= N <= 10^{2}

-10^{5 }<= A_{i} <= 10^{5}

**Example:**

**Input:**

1

-1 2 -1

6

-1 0 1 2 3 4

**Output:**

-9 -4 -4 -1 -1 0

**Explanation:**

After sorting, we get {-9, -4, -4, -1, -1, 0}

After applying the equation A*x*x + B*x + C on every element x we get, {-4,-1, 0, -1, -4, -9}

Input array is {-1, 0, 1, 2, 3, 4}.

Author: tanujyadav97

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

tushki | 198 |

namansharmacse17 | 110 |

TusharMittal3 | 70 |

adkeaesph | 57 |

deepakchoudhary11 | 48 |

ARUN_PUNDIR | 720 |

manishgupta8497 | 623 |

AMAN__JAIN | 596 |

Abhimanyu_kumar | 562 |

Bicky_Shokeen | 532 |

blackshadows | 5335 |

Ibrahim Nash | 5223 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4584 |

Login to report an issue on this page.