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.*;

public class B
{
PrintWriter out;
BufferedReader in;
StringTokenizer ss;

   static void dbg(String s){System.out.println(s);};
   static void deb(long x){System.out.println(x);};
   String next_token() throws IOException
   {while (!ss.hasMoreTokens())ss=new StringTokenizer(in.readLine());
    return ss.nextToken();}

   Double _double() throws IOException
   {return Double.parseDouble (next_token());}

   int _int() throws IOException
   {return Integer.parseInt (next_token());}

   long _long() throws IOException
   {return Long.parseLong (next_token());}

void run()throws IOException
{

in = new BufferedReader(new InputStreamReader(System.in));
out= new PrintWriter(System.out);
String name="";
/*in = new BufferedReader(new FileReader(name+".in"));
out = new PrintWriter(new File(name+".out"));  */
ss = new StringTokenizer(" ");
ss = new StringTokenizer(" ");
 int n=_int();
 int v=_int();v=Math.min(v,2*n);
 int n1=0;
 int n2=0;
 int A1[]=new int[n];
 int A2[]=new int[n];
    for(int i=0;i<n;i++){int t=_int();
        if(t==1){A1[n1]=_int()*n+i;n1++;}
         else{A2[n2]=_int()*n+i;n2++;}
    }
 Arrays.sort(A1,0,n1);
 Arrays.sort(A2,0,n2);
int ans=0;
    v=Math.min(v,n1+2*n2);
    int l=Math.min(v,n1);
    int r=(v-l)/2;
    int tek=0;
    for(int i=n1-l;i<n1;i++)tek+=A1[i]/n;
    for(int i=n2-r;i<n2;i++)tek+=A2[i]/n;
    ans=tek;int bestl=l;int bestr=r;
    while(l>0){
     tek-=A1[n1-l]/n;l--;
     while(l+2*r+1<v&&r<n2){r++;tek+=A2[n2-r]/n;}

    if(tek>ans){bestl=l;bestr=r;ans=tek;}
    }
    out.println(ans);
    for(int i=n1-bestl;i<n1;i++)out.print((A1[i]%n+1)+" ");
    for(int i=n2-bestr;i<n2;i++)out.print((A2[i]%n+1)+" ");
out.close();
}
public static void main(String[] args)throws Exception
{new B().run();}
}