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:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import java.util.*;

/**
 *
 * @author zLavigne
 */
public class Main {

    private static class boat implements Comparable {
        public boat(int i, int s, int c) {
            id = i;
            space = s;
            cap = c;
        }

        int id, space, cap;

        public int compareTo(Object o) {
            boat b = (boat) o;

            if (this.cap < b.cap) return 1;
            if (this.cap > b.cap) return -1;
            return 0;
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);

        int n, v;
        n = cin.nextInt();
        v = cin.nextInt();

        Vector<boat> v1 = new Vector<boat>();
        Vector<boat> v2 = new Vector<boat>();

        for (int i=0; i<n; ++i) {
            int id, space, cap;
            space = cin.nextInt(); cap = cin.nextInt();
            boat tmp = new boat(i+1, space, cap);
            if (tmp.space == 1) {
                v1.add(tmp);
            } else {
                v2.add(tmp);
            }
        }

        Collections.sort(v1);
        Collections.sort(v2);

        Vector<Integer> ans = new Vector<Integer>();

        long sum = 0;
        
        Vector<Long> sum1 = new Vector<Long>();
        Vector<Long> sum2 = new Vector<Long>();
        
        sum1.add((Long)(long)0);
        for(int i=0;i<v1.size();++i) {
            sum1.add(sum1.elementAt(i) + (long)(v1.elementAt(i).cap));
        }
        
        sum2.add((Long)(long)0);
        for(int i=0;i<v2.size();++i) {
            sum2.add(sum2.elementAt(i) + (long)(v2.elementAt(i).cap));
        }
        //System.out.println("" + sum1.size() + " " + sum2.size() + ":)");
        
        long max = -1;
        int maxv1=0;
        for(int i=0;i<sum1.size();++i) {
            if(i > v) break;
            if(sum1.elementAt(i) + sum2.elementAt(Math.min((v-i)/2, v2.size())) > max) {
                max = sum1.elementAt(i) + sum2.elementAt(Math.min((v-i)/2, v2.size()));
                maxv1 = i;
            }
        }

        int maxv2 = Math.min((v-maxv1)/2, v2.size());
        
        for(int i=0;i<maxv1;i++) {
            ans.add(v1.elementAt(i).id);
        }
        for(int i=0;i<maxv2;i++) {
            ans.add(v2.elementAt(i).id);
        }
        
        System.out.println(max);
        for(int i=0;i<ans.size();++i) {
            if(i>0)System.out.print(' ');

            System.out.print(ans.elementAt(i));
        }
        System.out.println("");

        /**
         * all false below
         */
/*
        boolean end = false;
        while (end == false) {

            if(v == 0) {
                end = true;
                continue;
            }

            if (v1.size() == 0) {
                while (v2.size() != 0 && v >= 2) {
                    sum += v2.elementAt(v2.size()-1).cap;
                    ans.add(v2.elementAt(v2.size()-1).id);
                    v2.remove(v2.size()-1);
                    v -= 2;
                }
                end = true;
            } else if (v2.size() == 0) {
                while (v1.size() != 0 && v >= 1) {
                    sum += v1.elementAt(v1.size()-1).cap;
                    ans.add(v1.elementAt(v1.size()-1).id);
                    v1.remove(v1.size()-1);
                    v -= 1;
                }
                end = true;
            } else if (v == 1) {
                sum += v1.elementAt(v1.size()-1).cap;
                ans.add(v1.elementAt(v1.size()-1).id);
                v1.remove(v1.size()-1);
                v -= 1;
                end = true;
            } else {
                long now2 = v2.elementAt(v2.size()-1).cap;

                long now1 = v1.elementAt(v1.size()-1).cap;
                if(v1.size()>1)now1 += v1.elementAt(v1.size()-2).cap;

                if(now2 >= now1) {
                    sum += v2.elementAt(v2.size()-1).cap;
                    ans.add(v2.elementAt(v2.size()-1).id);
                    v2.remove(v2.size()-1);
                    v -= 2;
                } else {
                    sum += v1.elementAt(v1.size()-1).cap;
                    ans.add(v1.elementAt(v1.size()-1).id);
                    v1.remove(v1.size()-1);
                    v -= 1;

                    //another
                    if(v1.size()>0) {
                        sum += v1.elementAt(v1.size()-1).cap;
                        ans.add(v1.elementAt(v1.size()-1).id);
                        v1.remove(v1.size()-1);
                        v -= 1;
                    }
                }
            }
        }

        System.out.println(sum);
        for(int i=0;i<ans.size();++i) {
            if(i>0)System.out.print(' ');

            System.out.print(ans.elementAt(i));
        }
        System.out.println("");
*/
    }

}