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:
//package Contest3;

import java.util.*;

public class main3B {
    public static Scanner enter = new Scanner(System.in);
    public static void main(String[] args) {
        int n=enter.nextInt();
        int V=enter.nextInt();
        ArrayList<lodka> V1=new ArrayList<>(100000);
        ArrayList<lodka> V2=new ArrayList<>(100000);
        ArrayList<Integer> notebook =new ArrayList<>(100000);
        for (int i = 0; i <n ; i++) {
            if(enter.nextInt()==2){
                V2.add(new lodka(enter.nextInt(),i+1));
            }
            else V1.add(new lodka(enter.nextInt(),i+1));
        }
        V1.sort(lodka::compareTo);
        V2.sort(lodka::compareTo);
       /* print(V1);
        print(V2);*/
        int gruz=0,firstSize=V1.size(),secondSize=V2.size(),ifir=0,isec=0;
        while(V>0){
            if(firstSize==0 && secondSize==0) break;
            else if(firstSize==0){
                V/=2;
                while(V>0 && secondSize>0){
                    gruz+=V2.get(isec).getGruztake();
                    notebook.add(V2.get(isec).getNumber());
                    isec++;
                    secondSize--;
                    V--;
                }
                break;
            }
            else if(secondSize==0){
                while(V>0 && firstSize>0){
                    gruz+=V1.get(ifir).getGruztake();
                    notebook.add(V1.get(ifir).getNumber());
                    ifir++;
                    firstSize--;
                    V--;
                }
                break;
            }
            if(firstSize==1 && V>1){
                if(V1.get(ifir).getGruztake()>=V2.get(isec).getGruztake()) {
                    gruz+=V1.get(ifir).getGruztake();
                    notebook.add(V1.get(ifir).getNumber());
                    V--;
                    firstSize=0;
                }
                else{
                    gruz+=V2.get(isec).getGruztake();
                    notebook.add(V2.get(isec).getNumber());
                    isec++;
                    secondSize--;
                    V-=2;
                }
                continue;
            }
            else if(V%2==1){
                gruz+=V1.get(ifir).getGruztake();
                notebook.add(V1.get(ifir).getNumber());
                V--;
                ifir++;
                firstSize--;
                continue;
            }
            else if(firstSize==1 && V==1){
                gruz+=V1.get(ifir).getGruztake();
                notebook.add(V1.get(ifir).getNumber());
                V--;
                break;
            }
            else{
                if(V1.get(ifir+1).getGruztake()+V1.get(ifir).getGruztake()>V2.get(isec).getGruztake()){
                    gruz+=V1.get(ifir+1).getGruztake()+V1.get(ifir).getGruztake();
                    notebook.add(V1.get(ifir).getNumber());
                    notebook.add(V1.get(ifir+1).getNumber());
                    V-=2;
                    ifir+=2;
                    firstSize-=2;
                }
                else{
                    gruz+=V2.get(isec).getGruztake();
                    notebook.add(V2.get(isec).getNumber());
                    isec++;
                    secondSize--;
                    V-=2;
                }
            }
            /*System.out.println(gruz+" Общий вес");
            print(V1);
            print(V2);*/
        }
        System.out.println(gruz);
        for (int i = 0; i <notebook.size() ; i++) {
            System.out.println(notebook.get(i));
        }
    }

    public static void print(TreeSet<lodka> V){
        Iterator<lodka> iter=V.iterator();
        while(iter.hasNext()){
            lodka tmp=iter.next();
            System.out.println("Gruz+ " + tmp.getGruztake()+" - № "+ tmp.getNumber());
        }
        System.out.println();
    }
}


class lodka implements Comparable<lodka> {
    private int gruztake, number;

    public lodka(int gruztake, int number) {
        this.gruztake = gruztake;
        this.number = number;
    }


    public int getGruztake() {
        return gruztake;
    }


    public int getNumber() {
        return number;
    }

    @Override
    public int compareTo(lodka o) {
        if(gruztake==o.getGruztake()){
            return number-o.getNumber();
        }
        else return -gruztake+o.getGruztake();
    }
}