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.io.BufferedReader;
import java.io.IOError;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.Comparable;
import java.util.*;

public class Main {
    static BufferedReader reader;
    public static String readString(){
        try {
            return reader.readLine().trim();
        } catch (IOException exception){
            throw new IOError(exception);
        }
    }
    public static int readInt(){
        return Integer.parseInt(readString());
    }
    public static int[] readInts(){
        String[] parts = readString().split(" ");
        int[] integers = new int[parts.length];
        for (int i = 0; i<integers.length; i++){
            integers[i] = Integer.parseInt(parts[i]);
        }
        return integers;
    }
    public static double readDouble(){
        return Double.parseDouble(readString());
    }
    public static double[] readDoubles(){
        String[] parts = readString().split(" ");
        double[] integers = new double[parts.length];
        for (int i = 0; i<integers.length; i++){
            integers[i] = Double.parseDouble(parts[i]);
        }
        return integers;
    }
    public static class Boat implements Comparable<Boat>{
        public final int n, capacity, size, efficiency;
        public Boat(int n, int capacity, int size) {
            this.n = n;
            this.capacity = capacity;
            this.size = size;
            this.efficiency = capacity * 2 / size;
        }

        @Override
        public int compareTo(Boat o) {
            return  o.efficiency - this.efficiency;
        }
    }

    public static void main(String[] args) {
        reader = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder builder = new StringBuilder();
        int[] vals = readInts();
        int num_vehicles = vals[0];
        int volume = vals[1];
        ArrayList<Boat> catamaran = new ArrayList<Boat>();
        ArrayList<Boat> kayaks = new ArrayList<Boat>();
        for (int i = 1; i <= num_vehicles; i++){
            vals = readInts();
            if (vals[0] == 1){
                kayaks.add(new Boat(i, vals[1], 1));
            } else{
                catamaran.add(new Boat(i, vals[1], 2));
            }
        }
        Collections.sort(catamaran);
        Collections.sort(kayaks);
        ListIterator<Boat> kayaksIterator = kayaks.listIterator();
        ListIterator<Boat> catamaranIterator = catamaran.listIterator();
        int remainingVolume = volume;
        int totalCapacity = 0;
        while (true){
            if (remainingVolume == 0){
                break;
            }
            if (remainingVolume%2 == 1 && kayaksIterator.hasNext()){
                Boat kayak = kayaksIterator.next();
                remainingVolume --;
                builder.append(kayak.n).append("\n");
                totalCapacity+=kayak.capacity;
                continue;
            }
            if (!catamaranIterator.hasNext()){
                if (!kayaksIterator.hasNext()){
                    break;
                }
                Boat kayak = kayaksIterator.next();
                remainingVolume --;
                builder.append(kayak.n).append("\n");
                totalCapacity+=kayak.capacity;
                continue;
            } else if (!kayaksIterator.hasNext()){
                if (remainingVolume >= 2){
                    Boat cat = catamaranIterator.next();
                    remainingVolume -=2;
                    builder.append(cat.n).append("\n");
                    totalCapacity+=cat.capacity;
                    continue;
                } else {
                    break;
                }
            }
            Boat cat = catamaranIterator.next();
            Boat kayak = kayaksIterator.next();
            if (!kayaksIterator.hasNext()){
                if (cat.capacity > kayak.capacity){
                    remainingVolume -=2;
                    builder.append(cat.n).append("\n");
                    totalCapacity+=cat.capacity;
                    kayaksIterator.previous();
                } else {
                    remainingVolume --;
                    builder.append(kayak.n).append("\n");
                    totalCapacity+=kayak.capacity;
                    catamaranIterator.previous();
                }
                continue;
            }
            Boat kayak2 = kayaksIterator.next();
            if (cat.capacity > kayak.capacity + kayak2.capacity){
                builder.append(cat.n).append("\n");
                totalCapacity+=cat.capacity;
                kayaksIterator.previous();
                kayaksIterator.previous();
            } else {
                builder.append(kayak.n).append("\n").append(kayak2.n).append("\n");
                totalCapacity+=kayak.capacity+kayak2.capacity;
                catamaranIterator.previous();
            }
            remainingVolume-=2;
        }
        builder.insert(0,"\n");
        builder.insert(0,totalCapacity);
        System.out.print(builder.toString());
    }
}