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.io.*;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.math.*;

public class B
{
        String line;
        StringTokenizer inputParser;
        BufferedReader is;
        FileInputStream fstream;
        DataInputStream in;
        String FInput="";
        
        void openInput(String file)
        {

                if(file==null)is = new BufferedReader(new InputStreamReader(System.in));//stdin
                else
                {
                        try{
                
                                
                        fstream = new FileInputStream(file);
                        in = new DataInputStream(fstream);
                        is = new BufferedReader(new InputStreamReader(in));
                        }catch(Exception e)
                        {
                                System.err.println(e);
                        }
                }

        }
        
        void readNextLine()
    	{
    		try {
    			line = is.readLine();
    			inputParser = new StringTokenizer(line, " ");
    			//System.err.println("Input: " + line);
    		} catch (IOException e) {
    			System.err.println("Unexpected IO ERROR: " + e);
    		}	
    		catch (NullPointerException e)
    		{
    			line=null;
    			
    		}
    		
    	}
        
        long NextLong()
        {
                String n = inputParser.nextToken();
                
                long val = Long.parseLong(n);
                
                 return val;
        }
        
        int NextInt()
        {
                String n = inputParser.nextToken();
                int val = Integer.parseInt(n);
                
                //System.out.println("I read this number: " + val);
                return val;
        }
        
        String NextString()
        {
                String n = inputParser.nextToken();
                return n;
        }
        
        void closeInput()
        {
                try {
                        is.close();
                } catch (IOException e) {
                        System.err.println("Unexpected IO ERROR: " + e);
                }
                        
        }
        
        
        public static void main(String [] argv)
        {
                String filePath=null;
                if(argv.length>0)filePath=argv[0];
                new B(filePath);
        }
        
        public void readFInput()
    	{
    		for(;;)
    		{
    			try
    			{
    				readNextLine();
    				FInput+=line+" ";
    			}
    			catch(Exception e)
    			{
    				break;
    			}
    		}
    		inputParser = new StringTokenizer(FInput, " ");
    	}
        
       
        public B(String inputFile)
        {
        	openInput(inputFile);
        	readNextLine();
        	int n=NextInt();
        	int v=NextInt();
        	
        	long ret=0;
        	
        	ArrayList <Vehicle> p1 = new ArrayList<Vehicle>();
        	ArrayList <Vehicle> p2 = new ArrayList<Vehicle>();
        	
        	for(int i=0; i<n; i++)
        	{
        		readNextLine();
        		int type=NextInt();
        		if(type==1)p1.add(new Vehicle(type,NextInt(),i+1));
        		else p2.add(new Vehicle(type,NextInt(),i+1));
        	}
        	
        	Collections.sort(p1);
        	Collections.sort(p2);
        	
        	int id1=0,id2=0;
        	
        	StringBuilder sb=new StringBuilder();
        	
        	if(((v&1)>0)&&(p1.size()>0))
        	{
        		v--;
        		ret+=p1.get(id1).capacity;
        		sb.append(p1.get(id1).id+" ");
        		id1++;
        		if((p1.size()&1)==0)
        		{
        			p1.add(new Vehicle(1,0,-1));
        		}
        	}
        	else
        	{
        		if((p1.size()&1)==1)
        		{
        			p1.add(new Vehicle(1,0,-1));
        		}
        	}
        	
        	
        	while(v>1)
        	{
        		int cap1=0,cap2=0;
        		if(id1<p1.size())cap1=p1.get(id1).capacity+p1.get(id1+1).capacity;
        		if(id2<p2.size())cap2=p2.get(id2).capacity;
        		if(cap1+cap2==0)break;
        		if(cap1>cap2)
        		{
        			ret+=p1.get(id1).capacity;
        			ret+=p1.get(id1+1).capacity;
        			sb.append(p1.get(id1).id+" ");
        			if(p1.get(id1+1).id>-1)sb.append(p1.get(id1+1).id+" ");
        			id1+=2;
        		}
        		else
        		{
        			ret+=p2.get(id2).capacity;
        			sb.append(p2.get(id2).id+" ");
        			id2++;
        		}
        		v-=2;
        	}
        	
        	System.out.println(ret);
        	if(sb.length()>0)sb.deleteCharAt(sb.length()-1);
        	System.out.println(sb);
            closeInput();		
    	}

		private class Vehicle implements Comparable<Vehicle>
		{
			int capacity,type;
			int dcp,id;
			
			Vehicle (int type, int cap, int id)
			{
				capacity=cap;
				this.type=type;
				dcp=capacity*2/type;
				this.id=id;
			}
			
			@Override
			public int compareTo(Vehicle d) {
				return d.dcp-dcp;
			}
			
		}



}