Ninja is having some health issues. So he decided to buy fruits to get nutrition. There are ‘N’ number of fruits. Each fruit has some amount of nutrition and a specific cost.
Ninja has ‘M’ units of money. You need to find the maximum amount of nutrition Ninja can get and the total cost to get maximum nutrition. The ninja can buy any number of fruits, but he can spend only at most ‘M’ units of money.
Note: If there are multiple values of costs possible for maximum nutrition, you need to find the minimum one.
Example:Suppose there are 3 fruits with costs 1, 2, 3 and nutrition 2, 2, 3 units respectively. Ninja has 3 units of money. Then, the ninja can take fruits with costs 1 and 2, having the maximum nutritional value of 4 units for a cost of 3 units.
1 <= N <= 1000
1 < = M <=1000
0 < = X <= 1000
0 < = Y <= 1000
Time Limit: 1 sec
2
9 4
1 2
2 3
4 5
5 7
6 3
7 4
9 2
11 12
Sample Output 1 :
12 8
0 0
Explanation of sample input 1 :
For the first test case:-
The ninja can select the fruits at indices ( 0 - based ) 0, 1, and 3, which constitutes 12 units of nutrition and 8 units of cost.
For the second test case:-
The Ninja can not buy any of these fruits so he will have his nutrition as 0 and cost also 0 as well
Sample Input 2 :
2
50 10
12 3
15 8
16 9
16 6
10 2
21 9
18 4
12 4
17 8
18 9
50 10
13 8
19 10
16 8
12 9
10 2
12 8
13 5
15 5
11 7
16 2
Sample Output 2:
26 49
32 48