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.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.StringTokenizer;


public class Prob3B {

	static class Boat implements Comparable<Boat>
	{
		int index;
		int size;
		int capacity;
		double value;
		
		public Boat(int i, int s, int c)
		{
			this.index = i;
			this.size = s;
			this.capacity = c;
			this.value = (double) this.capacity / (double) this.size;
		}
		
		public int getIndex()
		{
			return this.index;
		}

		public int getSize() {
			return this.size;
		}

		public int getCapacity() {
			return this.capacity;
		}
		
		public double getValue()
		{
			return this.value;
		}

		@Override
		public int compareTo(Boat arg0) {
			final int BEFORE = -1;
			final int EQUAL = 0;
			final int AFTER = 1;
			
			if(this.getValue() > arg0.getValue())
				return BEFORE;
			if(this.getValue() < arg0.getValue())
				return AFTER;
			return EQUAL;
		}	
	}
	
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer tokenizer = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(tokenizer.nextToken());
		int v = Integer.parseInt(tokenizer.nextToken());
		
		PriorityQueue<Boat> kayakPQ = new PriorityQueue<Boat>();
		PriorityQueue<Boat> catamaranPQ = new PriorityQueue<Boat>();
		int type = 0;
		int capacity = 0;
		
		for(int i=1; i<=n; i++)
		{
			tokenizer = new StringTokenizer(br.readLine());
			type = Integer.parseInt(tokenizer.nextToken());
			capacity = Integer.parseInt(tokenizer.nextToken());
			if(type==1)
				kayakPQ.add(new Boat(i, type, capacity));
			else
				catamaranPQ.add(new Boat(i, type, capacity));
		}
		
		int remainingVolume = v;
		int totalCapacity = 0;
		List<Integer> optimalIndices = new LinkedList<Integer>();
		Boat nextKayak = kayakPQ.poll();
		Boat nextCatamaran = catamaranPQ.poll();
		Boat sumTwoKayaks = null;
		
		while(remainingVolume>0 && (nextKayak!=null || nextCatamaran!=null))
		{
			if(remainingVolume==1 && nextKayak==null)
				break;
			
			//Get next candidates
			if(nextKayak==null)
				nextKayak = kayakPQ.poll();
			if(nextCatamaran==null)
				nextCatamaran = catamaranPQ.poll();
			
			//If odd spaces available, use kayak
			if(remainingVolume%2 != 0 && nextKayak!=null)
			{
				remainingVolume -= nextKayak.getSize();
				totalCapacity += nextKayak.getCapacity();
				optimalIndices.add(nextKayak.getIndex());
				nextKayak = kayakPQ.poll();			
			}
			
			//Decide if it's better to use one catamaran or 2 kayaks
			else
			{
				if(nextKayak!=null)
				{
					if(!kayakPQ.isEmpty())	//Make temp boat with capacity of next two kayaks combined
						sumTwoKayaks = new Boat(-1, nextKayak.getSize()+kayakPQ.peek().getSize(), nextKayak.getCapacity()+kayakPQ.peek().getCapacity());
					else
						sumTwoKayaks = new Boat(nextKayak.getIndex(), nextKayak.getSize()*2, nextKayak.getCapacity());
				}
				else
					sumTwoKayaks = null;
				
				if(nextCatamaran!=null)
				{
					if(sumTwoKayaks==null || nextCatamaran.getValue() > sumTwoKayaks.getValue())
					{
						remainingVolume -= nextCatamaran.getSize();
						totalCapacity += nextCatamaran.getCapacity();
						optimalIndices.add(nextCatamaran.getIndex());
						nextCatamaran = catamaranPQ.poll();
					}
					else
					{
						remainingVolume -= nextKayak.getSize();
						totalCapacity += nextKayak.getCapacity();
						optimalIndices.add(nextKayak.getIndex());
						nextKayak = kayakPQ.poll();
						if(nextKayak != null)
						{
							remainingVolume -= nextKayak.getSize();
							totalCapacity += nextKayak.getCapacity();
							optimalIndices.add(nextKayak.getIndex());
						}
						nextKayak = kayakPQ.poll();
					}
				}
				else	//nextCatamaran == null
				{
					if(nextKayak!=null)
					{
						remainingVolume -= nextKayak.getSize();
						totalCapacity += nextKayak.getCapacity();
						optimalIndices.add(nextKayak.getIndex());
						nextKayak = kayakPQ.poll();
					}
					if(nextKayak != null)
					{
						remainingVolume -= nextKayak.getSize();
						totalCapacity += nextKayak.getCapacity();
						optimalIndices.add(nextKayak.getIndex());
					}
					nextKayak = kayakPQ.poll();
				}
			}
		}
		
		StringBuilder sb = new StringBuilder();
		for(Integer i : optimalIndices)
			sb.append(i + " ");
		System.out.println(totalCapacity);
		System.out.println(sb);
	}
}