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:
//package codeforcesQuestions;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
public class cdf3b
{
	static void merge(int arr[], int l, int m, int r) 
    { 
        int n1 = m - l + 1; 
        int n2 = r - m; 
        int L[] = new int [n1]; 
        int R[] = new int [n2]; 
        for (int i=0; i<n1; ++i) 
            L[i] = arr[l + i]; 
        for (int j=0; j<n2; ++j) 
            R[j] = arr[m + 1+ j]; 
        int i = 0, j = 0; 
        int k = l; 
        while (i < n1 && j < n2) 
        { 
            if (L[i] <= R[j]) 
            { 
                arr[k] = L[i]; 
                i++; 
            } 
            else
            { 
                arr[k] = R[j]; 
                j++; 
            } 
            k++; 
        } 
        while (i < n1) 
        { 
            arr[k] = L[i]; 
            i++; 
            k++; 
        } 
        while (j < n2) 
        { 
            arr[k] = R[j]; 
            j++; 
            k++; 
        } 
    } 
    static void sort(int arr[], int l, int r) 
    { 
        if (l < r) 
        { 
            int m = (l+r)/2; 
            sort(arr, l, m); 
            sort(arr , m+1, r); 
            merge(arr, l, m, r); 
        } 
    } 
    public static int lowerBound(int[] array, int length, int value) 
	{
        int low = 0;
        int high = length;
        while (low < high) 
        {
            final int mid = (low + high) / 2;
            //checks if the value is less than middle element of the array
            if (value <= array[mid]) 
            {
                high = mid;
            } 
            else 
            {
                low = mid + 1;
            }
        }
        return low;
    }
	public static int upperBound(int[] array, int length, int value) 
	{
        int low = 0;
        int high = length;
        while (low < high) {
            final int mid = (low + high) / 2;
            if (value >= array[mid]) {
                low = mid + 1;
            } else {
                high = mid;
            }
        }
        return low;
    }
    static int gcd(int a, int b) 
    { 
      if (b == 0) 
        return a; 
      return gcd(b, a % b);  
    } 
    static long power(long n,long m)
    {
    	if(m==0)
    		return 1;
    	long ans=1;
    	while(m>0)
    	{
    		ans=ans*n;
    		m--;
    	}
    	return ans;
    }
    static int BinarySearch(int arr[], int x) 
    { 
        int l = 0, r = arr.length - 1; 
        while (l <= r) { 
            int m = l + (r - l) / 2; 
            if (arr[m] == x) 
                return m; 
            if (arr[m] < x) 
                l = m + 1; 
            else
                r = m - 1; 
        } 
        return -1; 
    } 
	public static void main(String args[])throws Exception
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int t=1;//Integer.parseInt(br.readLine());
		for(int i=1;i<=t;i++)
	    {
	        String s=br.readLine();
	        String str[]=s.split(" ");
	        int n=Integer.parseInt(str[0]);
	        int wei=Integer.parseInt(str[1]);
	        int copy=wei;
	        double arr[][]=new double[n][4];
	        for(int j=0;j<n;j++)
	        {
	        	s=br.readLine();
	        	String ss[]=s.split(" ");
	        	arr[j][0]=Integer.parseInt(ss[0]);
	        	arr[j][1]=Integer.parseInt(ss[1]);
	        	arr[j][2]=arr[j][1]/arr[j][0];
	        	arr[j][3]=j+1;
	        }
	        Arrays.sort(arr, (a, b) -> Double.compare(a[2], b[2]));
	        int j,prev=0,prevpos=-1;
	        long ans=0;
	        ArrayList <Integer> arrli=new ArrayList<Integer>();
	        for(j=n-1;j>=0;j--)
	        {
	        	if(wei<arr[j][0])
	        		break;
	        	if(arr[j][0]==1)
	        	{
	        		prev=(int)arr[j][1];
	        		prevpos=(int)arr[j][3];
	        	}
	        	ans=ans+(long)arr[j][1];
	        	wei-=arr[j][0];
	        	arrli.add((int)arr[j][3]);
	        }
	        if(wei==0||j<0)
	        {
	        	System.out.println(ans);
	        	for(j=0;j<arrli.size();j++)
	        		System.out.print(arrli.get(j)+" ");
	        	return;
	        }
	        int temp=0,pos2=0;
	        for(int k=j;k>=0;k--)
	        {
	        	if(arr[k][0]==1)
	        	{
	        		temp=(int)arr[k][1];
	        		pos2=(int)arr[k][3];
	        		break;
	        	}
	        }
	        int tempo=(int)arr[j][1];
	        if((temp+prev)>tempo)
	        {
	        	arrli.add(pos2);
	        	ans+=temp;
	        	System.out.println(ans);
	        	for(int k=0;k<arrli.size();k++)
	        		System.out.print(arrli.get(k)+" ");
	        	return;
	        }
	        else if(copy>1)
	        {
	        	ans-=prev;
	        	ans+=tempo;
	        	System.out.println(ans);
	        	for(int k=0;k<arrli.size();k++)
	        	{
	        		if(arrli.get(k)==prevpos)
	        		continue;
	        		System.out.print(arrli.get(k)+" ");
	        		
	        	}
	        	System.out.print((int)arr[j][3]);
	        	return;
	        }
	        else
	        {
	        	System.out.print("0");
	        }
	    }
	}
}