You have a backpack that can bear up to units of weight. Given objects, each with a weight and a value , compute the maximum sum of values achievable, in such a way that the sum of weights does not exceed . Take into account that objects cannot be cut: either you pick them, or you discard them.
Input consists of several cases. Every case begins with and , followed by pairs of integer numbers . Assume , , , and .
For every case, print the maximum value of the objects that can be stored in the backpack.
Input
10 3 7 3000 8 4000 3 2000 10 3 7 3000 8 6000 3 2000 2 4 1 3 1 5 1 7 1 7
Output
5000 6000 14