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

public class Contest3_B {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub

		BufferedReader kb = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(kb.readLine());
		int n = Integer.parseInt(st.nextToken());
		int v = Integer.parseInt(st.nextToken());
		int[][] kayaks = new int[n][3];
		int[][] catamarans = new int[n][3];
		int k = 0;
		int c = 0;
		for (int j = 0; j < n; j++) {
			st = new StringTokenizer(kb.readLine());
			int t = Integer.parseInt(st.nextToken());
			if (t == 1) {
				kayaks[k][0] = t;
				kayaks[k][1] = Integer.parseInt(st.nextToken());
				kayaks[k][2] = j + 1;
				k++;
			}
			else {
				catamarans[c][0] = t;
				catamarans[c][1] = Integer.parseInt(st.nextToken());
				catamarans[c][2] = j + 1;
				c++;
			}
		}
		Arrays.sort(kayaks, Comparator.comparing((int[] vehicle) -> (double) vehicle[1] / vehicle[0]));
		Arrays.sort(catamarans, Comparator.comparing((int[] vehicle) -> (double) vehicle[1] / vehicle[0]));
		kayaks = Arrays.copyOf(kayaks, k);
		catamarans = Arrays.copyOf(catamarans, c);
		k--;
		c--;
		int vv = v;
		int capacity = 0;
		ArrayList<Integer> boats = new ArrayList<Integer>();
		while (vv >= 2 && (k >= 0 || c >= 0)) {
			int kayak = 0; 
			if (k > 0)
				kayak = kayaks[k][1] + kayaks[k - 1][1];
			if (k > 0 && (c < 0 || kayak > catamarans[c][1])) {
				capacity += kayak;
				boats.add(kayaks[k][2]);
				boats.add(kayaks[k - 1][2]);
				k -= 2;
			}
			else if (c >= 0) {
				capacity += catamarans[c][1];
				boats.add(catamarans[c][2]);
				c--;
			}
			vv -= 2;
		}
		if (vv == 1 && kayaks.length > 0) {
			int nextK = 0;
			if (k >= 0) 
				nextK = kayaks[k][1];
			if (c >= 0 && kayaks[k + 1][1] + nextK < catamarans[c][1]) {
				capacity += catamarans[c][1] - kayaks[k + 1][1];
				boats.remove((Object) kayaks[k + 1][2]);
				boats.add(catamarans[c][2]);
			} else if (k >= 0) {
				capacity += kayaks[k][1];
				boats.add(kayaks[k][2]);
			}
		}
		System.out.println(capacity);
		System.out.println(boats.toString().replaceAll("[\\[\\],]", ""));
	}

}