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.ArrayList;
import java.util.Collections;
import java.util.Scanner;


public class Main {

	public static class WaterFloatyThing implements Comparable<WaterFloatyThing> {
		private int _n, _w;
		
		WaterFloatyThing(int n, int w) {
			_n = n; _w = w;
		}

		// Used as a helper function in summating the everything in main
		public void summate(int prevVal) {
			_w += prevVal;
		}
		
		public int n() {
			return _n;
		}
		
		public int w() {
			return _w;
		}
		
		@Override
		public int compareTo(WaterFloatyThing arg0) {
			return Integer.compare(_w, arg0.w());
		}
		
		@Override
		public String toString() {
			return Integer.toString(_n) + ":" + Integer.toString(_w);
		}
	}
	
	public static void main(String[] args) {
		
		// Read in all values
		int n, v;
		Scanner in = new Scanner(System.in);
		
		n = in.nextInt(); v = in.nextInt();
		
		ArrayList<WaterFloatyThing> kayaks = new ArrayList<WaterFloatyThing>(), catamarans = new ArrayList<WaterFloatyThing>();

		for(int i = 1; i <= n; i++) {
			if (in.nextInt() == 1) {
				kayaks.add(new WaterFloatyThing(i, in.nextInt()));
			} else {
				catamarans.add(new WaterFloatyThing(i, in.nextInt()));
			}
		}
		
		Collections.sort(kayaks);
		Collections.reverse(kayaks);
		Collections.sort(catamarans);
		Collections.reverse(catamarans);
		kayaks.add(0, new WaterFloatyThing(0, 0));
		catamarans.add(0, new WaterFloatyThing(0, 0));
		// Now because we have both kayaks and catamarans sorted, we can do something interesting - we
		//  can make the arrays a summation, which we can then use later to make computation elegant.
		
		for(int i = 1; i < kayaks.size(); i++) {
			kayaks.get(i).summate(kayaks.get(i - 1).w());
		}
		
		for(int i = 1; i < catamarans.size(); i++) {
			catamarans.get(i).summate(catamarans.get(i - 1).w());
		}
		
		// Now we have summations of values. Find the largest value we can get within the range -
		//  so start at all kayaks, increase catamarans by removing kayaks and compare with current
		//  max found.
		int largestResult = -1;
		int lnk = 0, lnc = 0;
		for(int nKayaks = (kayaks.size() - 1 >= v) ? v : kayaks.size() - 1; nKayaks >= 0; nKayaks--) {
			int nCatamarans = ((v - nKayaks) / 2 >= catamarans.size() - 1) ? catamarans.size() - 1 : ((v - nKayaks) / 2);
			int res = kayaks.get(nKayaks).w() + catamarans.get(nCatamarans).w();
			if (res > largestResult) {
				largestResult = res;
				lnk = nKayaks;
				lnc = nCatamarans;
			}
		}
		
		System.out.println(largestResult);
		
		for (int i = 1; i <= lnk; i++) {
			System.out.print(kayaks.get(i).n() + " ");
		}
		for(int i = 1; i <= lnc; i++) {
			System.out.print(catamarans.get(i).n() + " ");
		}
	}
}