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 Main implements Runnable {
	
        class Vehicle implements Comparable<Vehicle>{
            int id, sum;
            Vehicle(int id, int s){
                this.id = id; this.sum = s;
            }
            @Override
            public int compareTo(Vehicle b){
                return - (sum - b.sum);
            }
        }
        
	public void solve() throws IOException {
            int N = nextInt();
            int V = nextInt();
            
            ArrayList<Vehicle> type1 = new ArrayList<Vehicle>();
            ArrayList<Vehicle> type2 = new ArrayList<Vehicle>();
            for(int i = 0; i < N; i++){
                int type = nextInt();
                int p = nextInt();
                if(type == 1){
                    type1.add(new Vehicle(i+1, p));
                }
                else{
                    type2.add(new Vehicle(i+1, p));
                }
            }
            
            Collections.sort(type1);
            Collections.sort(type2);
            for(int i = 1; i < type1.size(); i++) type1.get(i).sum += type1.get(i-1).sum;
            for(int i = 1; i < type2.size(); i++) type2.get(i).sum += type2.get(i-1).sum;
            
            int answer = 0;
            int goodFirst = -1;
            int goodSecond = -1;
            int sz1 = type1.size();
            int sz2 = type2.size();
            
            for(int takeFirst = 0; takeFirst <= sz1 ; takeFirst++){
                int curProfit = 0;
                int tempVolume = V;
                
                int canFirst = Math.min(takeFirst, tempVolume);
                if(canFirst > 0){
                    curProfit += type1.get(canFirst - 1).sum;
                    tempVolume -= canFirst;
                }
                
                int canSecond = tempVolume / 2;
                canSecond = Math.min(canSecond, sz2);
                
                if(canSecond > 0){
                    curProfit += type2.get(canSecond - 1).sum;
                }
                
                if(curProfit > answer){
                    answer = curProfit;
                    goodFirst = canFirst - 1;
                    goodSecond = canSecond - 1;
                }
            }
            
            out.println(answer);
            for(int i = 0; i <= goodSecond; i++) out.print(type2.get(i).id + " ");
            for(int i = 0; i <= goodFirst; i++) out.print(type1.get(i).id + " ");
            out.println();
	}

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	//-----------------------------------------------------------
	public static void main(String[] args) {
		new Main().run();
	}

        public void debug(Object... arr){
            System.out.println(Arrays.deepToString(arr));
        }

        public void print1Int(int[] a){
                for(int i = 0; i < a.length; i++)
                        System.out.print(a[i] + " ");
                System.out.println();
        }
        
        public void print2Int(int[][] a){
                for(int i = 0; i < a.length; i++){
                        for(int j = 0; j < a[0].length; j++){
                                System.out.print(a[i][j] + " ");
                        }
                        System.out.println();
                }
        }
        
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
                        out = new PrintWriter(System.out);
			tok = null;
			solve();
			in.close();
                        out.close();
		} catch (IOException e) {
			System.exit(0);
		}
	}

	public String nextToken() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
        PrintWriter out;
	BufferedReader in;
	StringTokenizer tok;
}