eolymp
bolt
Try our new interface for solving problems
Problems

NP Knapsack problem

NP Knapsack problem

One of the classic NP - complete problems is the so-called Knapsack problem. It is formulated as follows.

n items are given, each of which is characterized by weight wi and usefulness pi. It is necessary to choose a certain set of these items so that the total weight of this set does not exceed w, and the total usefulness is maximum.

Input

First line contains positive integers n (1n20) and w (1w109). Next n lines with two integers are given: the weight of the i-th item wi and its usefulness pi (1wi, pi109).

Output

On the first line print the number of selected items and their total usefulness. On the second line print their numbers in ascending order (items are numbered starting from one in the order in which they are given at the input).

If there exists several outputs, choose the one with the smallest number of items. If after that the answer is still ambiguous, choose the set where the first item has the lowest possible number, from all such options, choose the one in which the second item has the lowest possible number, etc.

Time limit 1 second
Memory limit 128 MiB
Input example #1
2 10
10 100
9 80
Output example #1
1 100
1