题目描述
Our chef has opened a delivery agency. His prime moto is "earn money". He
is very strict on excessive consumption of petrol by his agency vehicles.
So he has fixed a daily limit on the amount of petrol consumed.
Now the management at his agency have got the following problem.
There are n vehicles in the agency n (1 ≤ n ≤ 100) represented
by numbers 1,2,3..n. Each kth vehicle can be used by the agency can be
used only if it has atleast k litres of fuel.
Each of the kth vehicle has initially pk litres of petrol.
The capacity of each kth vehicle is ck tonnes .
The goal of the management is to maximimize the total capacity in tonnes, given the max limit on petrol in litres.
Input
First line contains t the number of test cases.
Then follow 3 lines for each testcase.
First line : integers n (number of vehicles) and m , max litres of petrol that can be used.
Second line: n integers pk: initial capacity of kth vehicle.
Third line: n integers ck: capacity of kth vehicle
Output
Corresponding to each testcase print the max weight of delivery in tonnes that can be achieved by the management.
Constraints
1 ≤ n,m ≤ 1000
1 ≤ pk ≤ k
1 ≤ ck ≤ 10^9
Example
Input :
2
5 5
1 2 3 4 5
3 2 5 6 7
4 2
1 1 1 1
4 5 6 7
Output :
23
10
SAMPLE INPUT
2
5 5
1 2 3 4 5
3 2 5 6 7
4 2
1 1 1 1
4 5 6 7
SAMPLE OUTPUT
23
10
Explanation
1st testcase: Since their is no fuel requirement so maximum capacity will be sum of capacities of all vehicles
2nd testcase : Management will fill in 2 litres in the third vehicle. So total capacity will be 4+6=10 litres.
输入格式
见题面
输出格式
见题面