Problem: A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times bigger than kayaks (and occupy the space of 2 cubic metres).

Each waterborne vehicle has a particular carrying capacity, and it should be noted that waterborne vehicles that look the same can have different carrying capacities. Knowing the truck body volume and the list of waterborne vehicles in the boat depot (for each one its type and carrying capacity are known), find out such set of vehicles that can be taken in the lorry, and that has the maximum total carrying capacity. The truck body volume of the lorry can be used effectively, that is to say you can always put into the lorry a waterborne vehicle that occupies the space not exceeding the free space left in the truck body.

Input

The first line contains a pair of integer numbers n and v (1 ≤ n ≤ 105; 1 ≤ v ≤ 109), where n is the number of waterborne vehicles in the boat depot, and v is the truck body volume of the lorry in cubic metres. The following n lines contain the information about the waterborne vehicles, that is a pair of numbers ti, pi (1 ≤ ti ≤ 2; 1 ≤ pi ≤ 104), where ti is the vehicle type (1 – a kayak, 2 – a catamaran), and pi is its carrying capacity. The waterborne vehicles are enumerated in order of their appearance in the input file.

Output

In the first line print the maximum possible carrying capacity of the set. In the second line print a string consisting of the numbers of the vehicles that make the optimal set. If the answer is not unique, print any of them.

Examples

Input

3 2
1 2
2 7
1 3


Output

7
2

Solution (in JAVA):

Solution:
import java.util.*;

public class Lorry {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        String[] nAndV = s.nextLine().split(" ");
        int n = Integer.parseInt(nAndV[0]);
        int v = Integer.parseInt(nAndV[1]);

        List<Pair> kayaks = new ArrayList<>();
        List<Pair> catamarans = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            String[] typeAndCapacity = s.nextLine().split(" ");
            int capacity = Integer.parseInt(typeAndCapacity[1]);

            Pair e = new Pair(capacity, i + 1);
            if (typeAndCapacity[0].equals("1")) {
                kayaks.add(e);
            } else {
                catamarans.add(e);
            }
        }

        new Lorry().printResult(v, kayaks, catamarans);
    }

    private void printResult(int trackSizeLeft, List<Pair> kayaks, List<Pair> catamarans) {
        kayaks.sort(Comparator.comparingInt(f -> f.value));
        catamarans.sort(Comparator.comparingInt(f -> f.value));

        int kayaksIndex = kayaks.size() - 1;
        int catamaranIndex = catamarans.size() - 1;

        int carryingCapacity = 0;
        List<Integer> vehicles = new ArrayList<>();

        while (trackSizeLeft > 1 && kayaksIndex >= 0 && catamaranIndex >= 0) {
            Integer nextCatamaran = catamarans.get(catamaranIndex).value;
            Integer nextKayak = kayaks.get(kayaksIndex).value;
            if ((kayaksIndex == 0 && nextCatamaran > nextKayak) || (kayaksIndex > 0 && nextCatamaran > nextKayak + kayaks.get(kayaksIndex - 1).value)) {
                trackSizeLeft -= 2;
                carryingCapacity += nextCatamaran;
                vehicles.add(catamarans.get(catamaranIndex).index);
                catamaranIndex--;
            } else {
                trackSizeLeft--;
                carryingCapacity += nextKayak;
                vehicles.add(kayaks.get(kayaksIndex).index);
                kayaksIndex--;
            }
        }

        while (trackSizeLeft > 1 && catamaranIndex >= 0) {
            trackSizeLeft -= 2;
            carryingCapacity += catamarans.get(catamaranIndex).value;
            vehicles.add(catamarans.get(catamaranIndex).index);
            catamaranIndex--;
        }

        while (trackSizeLeft > 0 && kayaksIndex >= 0) {
            trackSizeLeft--;
            carryingCapacity += kayaks.get(kayaksIndex).value;
            vehicles.add(kayaks.get(kayaksIndex).index);
            kayaksIndex--;
        }

        System.out.println(carryingCapacity);
        System.out.println(listToString(vehicles));
    }

    private String listToString(List<Integer> l) {
        StringBuilder s = new StringBuilder();
        for (int v : l) {
            s.append(v);
            s.append(" ");
        }
        return s.toString();
    }

    private static class Pair {
        int value;
        int index;

        Pair(int v, int i) {
            value = v;
            index = i;
        }
    }
}