

The first line of input contains a ‘T’ number of test cases.
The first line of each test case contains an integer ‘N’ and ‘K’ denoting the number of rows in array ‘BOX’ and the limit on boxes on the truck. Then, ‘N’ lines follow.
Each line contains two space-separated integers denoting the row values i.e count of boxes and units per box.
For each test case, print a single line containing the maximum number of units that Ninja can deliver.
The output of each test case will be printed in a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 5
1 <= N <= 1000
1 <= BOX[i] <= 1000
1 <= K <= 10 ^ 6
Where ‘T’ is the number of test cases, ‘N’ is the number of rows in 2-D array ‘BOX’, and ‘K’ is the limit on boxes on the truck.
Time Limit: 1 sec
The idea here is to store all boxes units separately in a 1-D array and now from that array, we can easily find the maximum value which can be formed using boxes satisfying given condition on the box.
Algorithm:
The idea here is to optimize the space and time complexity for which we can think of sorting in the given 2-D array on the basis of the value of unitsperBox which helps in optimizing space as well as time as now we don’t consider a box of the same type as different.
Algorithm: