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.awt.Point;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import javax.net.ssl.TrustManagerFactorySpi;
import static java.lang.Math.*;
 
public class Solution3B {
        
        final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE")!=null;
        BufferedReader in;
        PrintWriter out;
        StringTokenizer tok = new StringTokenizer("");
        
        void init() throws FileNotFoundException{
                if (ONLINE_JUDGE){
                        in = new BufferedReader(new InputStreamReader(System.in));
                        out = new PrintWriter(System.out);
                }else{
                        in = new BufferedReader(new FileReader("input.txt"));
                        out = new PrintWriter("output.txt");
                }
        }
        
        String readString() throws IOException{
                while(!tok.hasMoreTokens()){
                        tok = new StringTokenizer(in.readLine());
                }
                return tok.nextToken();
        }
        
        int readInt() throws IOException{
                return Integer.parseInt(readString());
        }
        
        long readLong() throws IOException{
                return Long.parseLong(readString());
        }
        
        double readDouble() throws IOException{
                return Double.parseDouble(readString());
        }
        
        public static void main(String[] args){
                new Solution3B().run();
        }
        
        public void run(){
                try{
                        long t1 = System.currentTimeMillis();
                        init();
                        solve();
                        out.close();
                        long t2 = System.currentTimeMillis();
                        System.err.println("Time = "+(t2-t1));
                }catch (Exception e){
                        e.printStackTrace(System.err);
                        System.exit(-1);
                }
        }
        
        static class Utils {
 
                private Utils() {}
 
                public static void mergeSort(int[] a) {
                        mergeSort(a, 0, a.length - 1);
                }
 
                private static void mergeSort(int[] a, int leftIndex, int rightIndex) {
                        final int MAGIC_VALUE = 50;
                        if (leftIndex < rightIndex) {
                                if (rightIndex - leftIndex <= MAGIC_VALUE) {
                                        insertionSort(a, leftIndex, rightIndex);
                                } else {
                                        int middleIndex = (leftIndex + rightIndex) / 2;
                                        mergeSort(a, leftIndex, middleIndex);
                                        mergeSort(a, middleIndex + 1, rightIndex);
                                        merge(a, leftIndex, middleIndex, rightIndex);
                                }
                        }
                }
 
                private static void merge(int[] a, int leftIndex, int middleIndex, int rightIndex) {
                        int length1 = middleIndex - leftIndex + 1;
                        int length2 = rightIndex - middleIndex;
                        int[] leftArray = new int[length1];
                        int[] rightArray = new int[length2];
                        System.arraycopy(a, leftIndex, leftArray, 0, length1);
                        System.arraycopy(a, middleIndex + 1, rightArray, 0, length2);
                        for (int k = leftIndex, i = 0, j = 0; k <= rightIndex; k++) {
                                if (i == length1) {
                                        a[k] = rightArray[j++];
                                } else if (j == length2) {
                                        a[k] = leftArray[i++];
                                } else {
                                        a[k] = leftArray[i] <= rightArray[j] ? leftArray[i++] : rightArray[j++];
                                }
                        }
                }
 
                private static void insertionSort(int[] a, int leftIndex, int rightIndex) {
                        for (int i = leftIndex + 1; i <= rightIndex; i++) {
                                int current = a[i];
                                int j = i - 1;
                                while (j >= leftIndex && a[j] > current) {
                                        a[j + 1] = a[j];
                                        j--;
                                }
                                a[j + 1] = current;
                        }
                } 
        }
        
        class Transport implements Comparable<Transport>{
        	public Transport(int w, int m, int ind){
        		this.w = w;
        		this.m = m;
        		this.ind = ind;
        	}
        	@Override
			public int compareTo(Transport o) {
				if(this.w * 1.0 / this.m > o.w * 1.0 / o.m) return -1;
				if(this.w * 1.0 / this.m < o.w * 1.0 / o.m) return 1;
				if(this.m > o.m) return -1;
				if(this.m < o.m) return 1;
				return 0;					
			}
			public int w;
        	public int m;   
        	public int ind;
        }
        
        void solve() throws IOException{
        	int n = readInt();
        	int v = readInt();
        	Transport[] transports = new Transport[n];
        	for(int i = 0; i < n; i++){
        		int a = readInt();
        		int b = readInt();
        		transports[i] = new Transport(b, a, i);
        	}
        	Arrays.sort(transports);
        	int curN = v; 
        	int curW = 0;
        	int lastCat = -1;
        	int lastLod = -1;
        	int preLastLod = -1;
        	boolean[] isImpressed = new boolean[n];
        	ArrayList<Transport> impressed = new ArrayList<Solution3B.Transport>();
        	for(int i = 0; i < n; i++){
        		if(transports[i].m <= curN){
        			curN -= transports[i].m;
        			curW += transports[i].w;
        			isImpressed[i] = true;
        			impressed.add(transports[i]);
        			if(transports[i].m == 1){
        				preLastLod = lastLod;
        				lastLod = i;
        			}
        		}
        		else{
        			if(transports[i].m == 2)
        				if(lastCat == -1)
        					lastCat = i;
        		}
        	}
        	if(curN == 0 && lastCat != -1 && lastLod != -1 && preLastLod != -1){
        		int w1 = transports[lastLod].w + transports[preLastLod].w;
        		int wCat = transports[lastCat].w;
        		if(wCat > w1){
        				curW = curW + wCat - w1;
        				isImpressed[lastLod] = isImpressed[preLastLod] = false;
        				isImpressed[lastCat] = true;
        		}
        	}
        	if(curN == 1 && lastCat != -1 && lastLod != -1){
        		int w1 = transports[lastLod].w;
        		int wCat = transports[lastCat].w;
        		if(wCat > w1){
    				curW = curW + wCat - w1;
    				isImpressed[lastLod] = false;
    				isImpressed[lastCat] = true;
        		}
        	}
        	out.println(curW);
        	for(int i = 0; i < n; i++){
        		if(isImpressed[i])
        			out.print((transports[i].ind + 1) + " ");        			
        	}
        }
        
        static double distance(long x1, long y1, long x2, long y2){
        	return Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
        }
        
        static long gcd(long a, long b){
        	while(a != b){
        		if(a < b) a -=b;
        		else b -= a;
        	}
        	return a;
        }
        
        static long lcm(long a, long b){
        	return a * b /gcd(a, b);
        }
}