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.*;
import java.lang.*;
import java.io.*;

public class boatsboatsboats
{
    public static class boat{
        public int size;
        public int capacity;
        public int position;
        
        
        public boat() {
            size = 0;
            capacity = 0;
            position = -1;
        }
    }
    
    static Comparator<boat> comp = new Comparator<boat>() {
        @Override
        public int compare(boat A, boat B) {
            int toreturn = B.capacity/B.size - A.capacity/A.size;//descending
            if(toreturn != 0) return toreturn;
            
            if( ((double)B.capacity)/B.size -  ((double)A.capacity)/A.size > 0) return 1;
            if( ((double)B.capacity)/B.size -  ((double)A.capacity)/A.size < 0) return -1;
            
            return toreturn;
        }
    };
    
    
    public static void main (String[] args) throws java.lang.Exception
    {
       Scanner sc = new Scanner(System.in);
       int numBoats = sc.nextInt();
       int truckCapacity = sc.nextInt();
       
       boat[] singleboats = new boat[numBoats];
       boat[] doubleboats = new boat[numBoats];
       int numSingles = 0;
       int numDoubles = 0;

       for(int i=0;i<numBoats;i++) {
           int size = sc.nextInt();
           if(size == 1) {
               singleboats[numSingles] = new boat();
               singleboats[numSingles].size = 1;
               singleboats[numSingles].capacity = sc.nextInt();
               singleboats[numSingles].position = i+1;
               numSingles++;
           }
           else {
               doubleboats[numDoubles] = new boat();
               doubleboats[numDoubles].size = 2;
               doubleboats[numDoubles].capacity = sc.nextInt();
               doubleboats[numDoubles].position = i+1;
               numDoubles++;
           }
          
       }
       
        Arrays.sort(singleboats, 0, numSingles, comp);
        Arrays.sort(doubleboats, 0, numDoubles, comp);
       
       /*
        System.out.println("The singlesarray after sorting is:");
        for(int i = 0;i<numSingles;i++) {
           System.out.print(singleboats[i].position +"("+singleboats[i].capacity+")"+ " ");
        }
        System.out.println("The doublesarray after sorting is:");
        for(int i = 0;i<numDoubles;i++) {
           System.out.print(doubleboats[i].position +"("+singleboats[i].capacity+")"+ " ");
        }
       */
       
        StringBuilder sb = new StringBuilder();
        int spaceUsed = 0;
        int capacity = 0;
        int singleBoatBestIndex = 0;
        int doubleBoatBestIndex = 0;
        
        if(truckCapacity %2 == 1 && numSingles > 0) {
            sb.append(singleboats[singleBoatBestIndex].position+" ");
            spaceUsed += 1;
            capacity += singleboats[singleBoatBestIndex].capacity;
            singleBoatBestIndex++;
        }
        
        int doubleCap = 0;
        int singleCap = 0;
        if(doubleBoatBestIndex<numDoubles)
            doubleCap = doubleboats[doubleBoatBestIndex].capacity;
        if(singleBoatBestIndex < numSingles)
            singleCap = singleboats[singleBoatBestIndex].capacity;
        if(singleBoatBestIndex+1 < numSingles)
            singleCap += singleboats[singleBoatBestIndex+1].capacity;
        while(truckCapacity-spaceUsed >= 2) {
            
            if(doubleCap > singleCap) {
                sb.append(doubleboats[doubleBoatBestIndex].position+" ");
                spaceUsed +=2;
                capacity +=doubleCap;
                doubleBoatBestIndex++;
                if(doubleBoatBestIndex < numDoubles) {
                    doubleCap = doubleboats[doubleBoatBestIndex].capacity;
                }
                else {doubleCap = 0;}
            }
            else if(singleCap > 0) {
                sb.append(singleboats[singleBoatBestIndex].position+" ");
                capacity += singleboats[singleBoatBestIndex].capacity;
                spaceUsed++;
                if(singleBoatBestIndex+1 < numSingles) {
                    sb.append(singleboats[singleBoatBestIndex+1].position+" ");
                    capacity += singleboats[singleBoatBestIndex+1].capacity;
                    spaceUsed++;
                }
                singleBoatBestIndex += 2;
                if(singleBoatBestIndex < numSingles) {
                    singleCap = singleboats[singleBoatBestIndex].capacity;
                    if(singleBoatBestIndex+1 < numSingles)
                        singleCap += singleboats[singleBoatBestIndex+1].capacity;
                }
                else singleCap = 0;
            }
            else {break;}//the boats didn't fill the truck.
        }
        
        
        
        
       
       
       System.out.println(capacity);
       System.out.println(sb.toString());
    }
}