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:
public class Driver {
	
	static class Vehicle implements Comparable<Vehicle> {
		public int s, i;
		Vehicle(int s, int i) {
			this.s = s;
			this.i = i;
		}
		@Override
		public int compareTo(Vehicle v) {
			return s - v.s;
		}
	}
	
	static java.util.List<Integer> indicies = new java.util.ArrayList<>();
	static java.util.List<Vehicle> kayaks = new java.util.ArrayList<>();
	static java.util.List<Vehicle> catamarans = new java.util.ArrayList<>();
	static Vehicle[] sortedKayaks;
	static Vehicle[] sortedCatamarans;
	static int kSize;
	static int cSize;
	static int v;
	static int n;
	
	public static void main(String[] args) throws java.io.IOException {
		java.io.InputStreamReader isr = new java.io.InputStreamReader(System.in);
		java.io.BufferedReader in = new java.io.BufferedReader(isr);
		
		
		String[] values = in.readLine().split(" ");
		n = Integer.parseInt(values[0]);
		v = Integer.parseInt(values[1]);
		
		int type;
		int capacity;
		for (int i = 0; i < n; i++) {
			values = in.readLine().split(" ");
			type = Integer.parseInt(values[0]);
			capacity = Integer.parseInt(values[1]);
			if (type == 1)
				kayaks.add(new Vehicle(capacity, i+1));
			else
				catamarans.add(new Vehicle(capacity, i+1));
		}
		
		kSize = kayaks.size();
		if (kSize > 1) {
			sortedKayaks = new Vehicle[kSize];
			kayaks.toArray(sortedKayaks);
			quickSort(sortedKayaks);
			kayaks.clear();
			kayaks.addAll(java.util.Arrays.asList(sortedKayaks));
		}
		
		cSize = catamarans.size();
		if (cSize > 1) {
			sortedCatamarans = new Vehicle[cSize];
			catamarans.toArray(sortedCatamarans);
			quickSort(sortedCatamarans);
			catamarans.clear();
			catamarans.addAll(java.util.Arrays.asList(sortedCatamarans));
		}
		
		System.out.println(fillCapacity());
		for (Integer i : indicies) {
			System.out.print(i + " ");
		}
		in.close();
	}
	
	
	public static int fillCapacity() {
		if (v == 0)
			return 0;
		if (v == 1) {
			if (kSize < 1)
				return 0;
			Vehicle k = kayaks.get(kSize-1);
			indicies.add(k.i);
			return k.s;
		}
		if (kSize < 1 && cSize < 1){
			return 0;
		}
		boolean onlyOne = false;
		if (v % 2 != 0 && kSize < 3) {
			onlyOne = true;
		}
		int cCap = 0;
		int kCap = 0;
		Vehicle c = new Vehicle(0,-1);
		Vehicle k1 = new Vehicle(0,-1);
		Vehicle k2 = new Vehicle(0,-1);
		
		if (cSize > 0) {
			c = catamarans.get(cSize-1);
			cCap = c.s;
		}
		if (kSize > 0) {
			k1 = kayaks.get(kSize-1);
			kCap += k1.s;
			if (kSize > 1 && !onlyOne) {
				k2 = kayaks.get(kSize-2);
				kCap += k2.s;
			}
		}
		
		if (cCap > kCap) {
			indicies.add(c.i);
			catamarans.remove(cSize-1);
			cSize--;
			v -= 2;
			return cCap + fillCapacity();
		} else {
			indicies.add(k1.i);
			kayaks.remove(kSize-1);
			kSize--;
			v--;
			return k1.s + fillCapacity();
		}
	}
	
	public static <T extends Comparable<? super T>> T[] quickSort(T[] array) {
        sort(0, array.length - 1, array);
        return array;
    }
	
	public static <T extends Comparable<? super T>> void sort(int low, int high, T[] array) {
        if (low >= high) return;
        int p = partition(low, high, array);
        sort(low, p, array);
        sort(p + 1, high, array);
    }
	
	private static <T extends Comparable<? super T>> int partition(int low, int high, T[] array) {
        T pivot = array[low];

        int i = low - 1;
        int j = high + 1;
        while (i < j)
        {
            i++; 
            while (array[i].compareTo(pivot) < 0) 
                i++;
            j--; 
            while (array[j].compareTo(pivot) > 0) 
                j--;
            if (i < j) 
                swap(i, j, array);
         }
         return j;
      }

    private static <T extends Comparable<? super T>> void swap(int i, int j, T[] array) {
        T temp = array[i];
        array[i] = array[j];
        array[j] = temp;
    }
}