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.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Spencer on 1/30/2015.
 */
public class CF3B {

    public static void main(String[] args) throws IOException {
        BufferedReader buff = new BufferedReader((new InputStreamReader(System.in)));

        ArrayList<Integer> kayaks = new ArrayList<Integer>();
        ArrayList<Integer> catamarans = new ArrayList<Integer>();
        ArrayList<PairSet> watercraftList = new ArrayList<PairSet>();
        int totalCarryingCapacity = 0;

        String firstLineInput = buff.readLine();
        int N = Integer.parseInt(firstLineInput.split(" ")[0]);
        int V = Integer.parseInt(firstLineInput.split(" ")[1]);

        Map<String, ArrayList<Integer>> allInput = new HashMap<String, ArrayList<Integer>>();

        for(int i=0; i<N; i++) {
            String[] watercraft = buff.readLine().split(" ");
            if(watercraft[0].equals("1")) {
                kayaks.add(Integer.parseInt(watercraft[1]));
            } else {
                catamarans.add(Integer.parseInt(watercraft[1]));
            }
            PairSet pair = new PairSet(Integer.parseInt(watercraft[0]), Integer.parseInt(watercraft[1]));
            ArrayList<Integer> array;
            if(allInput.containsKey(pair.key())) {
                array = allInput.get(pair.key());
            } else {
                array = new ArrayList<Integer>();
            }
            array.add(i);
            allInput.put(pair.key(), array);
        }

        Collections.sort(kayaks);
        Collections.reverse(kayaks);
        Collections.sort(catamarans);
        Collections.reverse(catamarans);

        if(V % 2 != 0 && kayaks.size() > 0) {
            // it's odd, make it even
            totalCarryingCapacity += kayaks.get(0);
            watercraftList.add(new PairSet(1, kayaks.get(0)));
            kayaks.remove(0);
            V--;
        }

        while(V > 0) {

            if(V > 1) {
                int kayakSize = 0;
                int catamaranSize = 0;

                if(catamarans.size() == 0 && kayaks.size() == 0) break;

                if(catamarans.size() > 0) catamaranSize = catamarans.get(0);
                if(kayaks.size() > 1) {
                    kayakSize = kayaks.get(0) + kayaks.get(1);
                } else if (kayaks.size() > 0) {
                    kayakSize = kayaks.get(0);
                }

                if(kayakSize > catamaranSize) {
                    totalCarryingCapacity += kayakSize;
                    if(kayaks.size() > 1) {
                        watercraftList.add(new PairSet(1, kayaks.get(0)));
                        watercraftList.add(new PairSet(1, kayaks.get(1)));
                        kayaks.remove(0);
                        kayaks.remove(0);
                        V-=2;
                    } else
                    {
                        watercraftList.add(new PairSet(1, kayaks.get(0)));
                        kayaks.remove(0);
                        V--;
                    }
                } else {
                    totalCarryingCapacity += catamaranSize;
                    watercraftList.add(new PairSet(2, catamarans.get(0)));
                    catamarans.remove(0);
                    V-=2;
                }

            } else if(kayaks.size() > 0) {
                // just do a kayak
                totalCarryingCapacity += kayaks.get(0);
                watercraftList.add(new PairSet(1, kayaks.get(0)));
                kayaks.remove(0);
                V--;
            } else {
                break;
            }
        }

        PrintWriter printWriter = new PrintWriter(System.out);
        StringBuffer outputString = new StringBuffer();
        outputString.append(totalCarryingCapacity + "\n");

        for(int i=0; i < watercraftList.size(); i++) {
            PairSet selectedWC = watercraftList.get(i);
            ArrayList<Integer> array = allInput.get(selectedWC.key());
            int index = array.get(array.size()-1);
            array.remove(array.size()-1);
            allInput.put(selectedWC.key(), array);
            outputString.append((index+1) + " ");
        }
        printWriter.println(outputString);
        printWriter.close();
    }

    public static int getIndexOfPair(PairSet pair, ArrayList<PairSet> allInput)
    {
        for(int i=0; i<allInput.size(); i++) {
            PairSet comp = allInput.get(i);
            if(comp.x == pair.x && comp.y == pair.y) return i;
        }

        return -1;
    }

    public static class PairSet
    {
        public int x;
        public int y;
        public PairSet(int x, int y) {
            this.x = x;
            this.y = y;
        }
        public String key () {
            return x + " " + y;
        }
    }

//  public static class PWC
//  {
//      PWC(int capacity, )
//  }
}