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.*;
public class LorryCapacity {
static class Items implements Comparable<Items>{
	 long cap;
	 int index;
	 int index1;
     public Items(int index,long cap){
    	 this.cap = cap;
    	 this.index = index + 1;
    	 this.index1 = 0;
     }
     public Items(int index, int index1, long cap){
    	 this.cap = cap;
    	 this.index = index;
    	 this.index1 = index1;
     }
     public int compareTo(Items x){
    	 if(this.cap - x.cap > 0) return -1;
    	 else if(this.cap - x.cap == 0) return 0;
    	 else return 1;
     }	 
	}
public static void main(String[] args){
	Scanner input = new Scanner(System.in);
	int n = input.nextInt();
	long v = input.nextLong();
	long vehicleList[][] = new long[n][2];
	ArrayList<Items> cap_kay = new ArrayList<Items>();
	ArrayList<Items> cap_all= new ArrayList<Items>();
	int kayIndex = 0;
	int catIndex = 0;
	for(int i  = 0 ; i < n; i++){
		vehicleList[i][0] = input.nextInt();
		vehicleList[i][1] = input.nextLong();
		if(vehicleList[i][0] == 1)
			cap_kay.add(new Items(i,vehicleList[i][1]));
		else if(vehicleList[i][0] == 2)
			cap_all.add(new Items(i, vehicleList[i][1]));		
	   }
	Collections.sort(cap_kay);

    long capacity = 0;
    ArrayList index = new ArrayList();
	if(v == 1 && cap_kay.size() > 0){
	  System.out.println(cap_kay.get(0).cap);
	  System.out.println(1);
	  return;
	}
	else if (v == 1 && cap_kay.size() == 0)
	{
		System.out.println(0);
		return;
	}
	int start = 0;
	if(v % 2 ==1 && cap_kay.size() > 0){
		index.add(cap_kay.get(0).index);
		capacity += cap_kay.get(0).cap;
		v--;
		start = 1;
	}
	int i = start;
	for(;i < cap_kay.size() - 1; i+=2)
		cap_all.add(new Items(cap_kay.get(i).index, cap_kay.get(i+1).index,cap_kay.get(i).cap + cap_kay.get(i+1).cap));
	    if( i == cap_kay.size() - 1)
	    	cap_all.add(cap_kay.get(i));
	Collections.sort(cap_all);
	for( int j = 0 ; v > 0 && j < cap_all.size();j++){
		index.add(cap_all.get(j).index);
		index.add(cap_all.get(j).index1);
		capacity += cap_all.get(j).cap;
		v -= 2;
	}
	System.out.println(capacity);
	for( int j = 0 ; j < index.size(); j++){
		if(Integer.valueOf(String.valueOf(index.get(j))) != 0)
	    System.out.print(index.get(j) + " ");
	    }
}

}