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 Solution
{
    	public static void main(String[] args) throws java.lang.Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		StringTokenizer st = new StringTokenizer(br.readLine());
 
		int n = Integer.parseInt(st.nextToken());
		int cap = Integer.parseInt(st.nextToken());
 
		int[][] a = new int[n][3];
		for (int i = 0; i < n; i++) {
			st = new StringTokenizer(br.readLine());
			a[i][0] = Integer.parseInt(st.nextToken());
			a[i][1] = Integer.parseInt(st.nextToken());
			a[i][2] = i + 1;
		}
		Arrays.sort(a, (x, y) -> y[1] - x[1]);
		int[][] b = new int[n][3];
		int j = 0, k = 0;
		for (int i = 0; i < n; i++) {
			if (a[i][0] == 1) {
				a[j][0] = a[i][0];
				a[j][1] = a[i][1];
				a[j++][2] = a[i][2];
			} else {
				b[k][0] = a[i][0];
				b[k][1] = a[i][1];
				b[k++][2] = a[i][2];
			}
		}
 
		int p1 = 0, p2 = 0, p = 0, last = -1;
		int ans = 0;
		int[] result = new int[n];
 
		while (p1 < j - 1 && p2 < k && cap > 1) {
			if (a[p1][1] + a[p1 + 1][1] > b[p2][1]) {
				ans += a[p1][1] + a[p1 + 1][1];
				result[p++] = a[p1++][2];
				last = p;
				result[p++] = a[p1++][2];
			} else {
				ans += b[p2][1];
				result[p++] = b[p2++][2];
			}
			cap -= 2;
		}
 
		if (cap > 0) {
			while (cap > 1 && p1 == j - 1 && p2 < k) {
				if (a[p1][1] > b[p2][1]) {
					ans += a[p1][1];
					last = p;
					result[p++] = a[p1++][2];
					cap--;
				} else { 
					ans += b[p2][1];
					result[p++] = b[p2++][2];
					cap -= 2;
				}
			}
			while(cap>0 && p1<j && p2==k) {
				ans += a[p1][1];
				result[p++] = a[p1++][2];
				cap--;
			}
			while (cap > 1 && p2 < k) {
				ans += b[p2][1];
				result[p++] = b[p2++][2];
				cap -= 2;
			}
			if (cap == 1) {
				int max1 = ans+((p1<j)?a[p1][1]:0);
				int max2 = ans + ((p2<k && p1 > 0 ) ? (b[p2][1]-a[p1-1][1]):0);
				if(ans < Math.max(max1, max2)) {
					if(max1 < max2) result[last] = b[p2][2];
				    else result[p++] = a[p1][2];
				}
				ans = Math.max(max1, max2);
			}
		}
		result = Arrays.copyOfRange(result, 0, p);
		out.println(ans);
		for (int r : result)
			out.print(r + " ");
		out.close();
	}
}