Because of Eid-ul-Fitr, there is a BIG OFFER at your nearest super shop. You have decided to go shopping with your family at that super shop.
In the super shop, there are types of products. The rule of the offer is that each person can buy each type of product only once, but they can buy multiple products of different types. Every product have price and weight written on it.
You and your family want to buy as many valuable products as possible, but there is a limitation. Since each person is of a different age, they cannot carry the same amount of weight. Your have persons in your family including you. You know person can carry maximum amount of weight.
Now your role is to create a master plan and calculate the maximum value of products that you and your family can buy from the offer.
The first line contains one integer — the number of test cases. Then test cases follow.
Each test case begins with a single integer — indicates the number of products. Then follows lines, each containing two integers: and — indicate the price of the product and the weight of the product respectively. Next line contains a single integer — the number of persons in your family including you. Next lines contains maximal weight that can carry by person from your family.
For every test case output a single integer — the maximal value of products you and your family can buy using the offer.
Input | Output |
---|---|
1 3 32 20 8 10 93 30 2 27 25 | 64 |
Be careful about the newline(‘\n’) at the end.