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 final class code
// class code
// public class Solution
{
static void solve()throws IOException
{
    int n=nextInt();
    int v=nextInt();
    ArrayList<Pair> tlist=new ArrayList<>();
    ArrayList<Pair> clist=new ArrayList<>();
    tlist.add(null);
    clist.add(null);
    for(int i=1;i<=n;i++)
    {
        int type=nextInt();
        int cap=nextInt();
        if(type==1)
            tlist.add(new Pair(cap,i));
        else
            clist.add(new Pair(cap,i));
    }
    int tn=tlist.size()-1;
    int cn=clist.size()-1;
    Collections.sort(tlist.subList(1,tn+1));
    Collections.sort(clist.subList(1,cn+1));
    // debug(tlist,clist);
    int sumc[]=new int[cn+1];
    int sumt[]=new int[tn+1];
    for(int i=1;i<=cn;i++)
        sumc[i]=sumc[i-1]+(int)clist.get(i).first;
    for(int i=1;i<=tn;i++)
        sumt[i]=sumt[i-1]+(int)tlist.get(i).first;
    int max=-1;
    int maxc=-1;
    int maxt=-1;
    for(int i=0;i<=cn;i++)
    {
        if(i*2<=v)
        {
            int j=min(v-2*i,tn);
            if(sumc[i]+sumt[j]>max)
            {
                max=sumc[i]+sumt[j];
                maxc=i;
                maxt=j;
            }
        }
    }
    out.println(max);
    for(int i=1;i<=maxc;i++)
        out.print(clist.get(i).second+" ");
    for(int i=1;i<=maxt;i++)
        out.print(tlist.get(i).second+" ");
    
}
///////////////////////////////////////////////////////////
public static void main(String args[])throws IOException
{
br=new BufferedReader(new InputStreamReader(System.in));
out=new PrintWriter(new BufferedOutputStream(System.out));
random=new Random();

solve();

// int t=nextInt();
// for(int i=1;i<=t;i++)
// {
// // out.print("Case #"+i+": ");
// solve();
// }

out.close();
}

static final long mod=(long)(1e9+7);
static final int inf=(int)(1e9+1);
// static final long inf=(long)(1e18);

static class Pair<T extends Comparable<T>,V extends Comparable<V>> implements Comparable<Pair<T,V>>
{
    T first;
    V second;
    Pair(T a,V b)
    {
        first=a;
        second=b;
    }
    public int compareTo(Pair<T,V> p)
    {
        return -first.compareTo(p.first);
    }
    public String toString()
    {
        return first.toString()+" "+second.toString();
    }
    public int hashCode()
    {
        int hash=7;
        hash = 31*hash+(first!=null?first.hashCode():0);
        hash = 31*hash+(second!=null?second.hashCode():0);
        return hash;
    }
    public boolean equals(Object o)
    {
        if(this==o)
        return true;
        if(o instanceof Pair)
        {
            Pair p=(Pair)o;
            if(first!=null?!first.equals(p.first):p.first!=null)
                return false;
            if(second!=null?!second.equals(p.second):p.second!=null)
                return false;
            return true;
        }
        return false;
    }
}

static int max(int ... a)
{
int ret=a[0];
for(int i=1;i<a.length;i++)
ret=Math.max(ret,a[i]);
return ret;
}
static int min(int ... a)
{
int ret=a[0];
for(int i=1;i<a.length;i++)
ret=Math.min(ret,a[i]);
return ret;
}
static void debug(Object ... a)
{
System.out.print("> ");
for(int i=0;i<a.length;i++)
System.out.print(a[i]+" ");
System.out.println();
}
static void debug(int a[]){debuga(Arrays.stream(a).boxed().toArray());}
static void debug(long a[]){debuga(Arrays.stream(a).boxed().toArray());}
static void debuga(Object a[])
{
System.out.print("> ");
for(int i=0;i<a.length;i++)
System.out.print(a[i]+" ");
System.out.println();
}
static Random random;
static BufferedReader br;
static StringTokenizer st;
static PrintWriter out;
static String nextToken()throws IOException
{
while(st==null || !st.hasMoreTokens())
st=new StringTokenizer(br.readLine());
return st.nextToken();
}
static String nextLine()throws IOException
{
return br.readLine();
}
static int nextInt()throws IOException
{
return Integer.parseInt(nextToken());
}
static long nextLong()throws IOException
{
return Long.parseLong(nextToken());
}
static double nextDouble()throws IOException
{
return Double.parseDouble(nextToken());
}
}