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 static java.lang.Math.*;

public class ProblemB_03 {
    
    final boolean ONLINE_JUDGE=System.getProperty("ONLINE_JUDGE")!=null;
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok=new StringTokenizer("");
    
    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in=new BufferedReader(new InputStreamReader(System.in));
            out =new PrintWriter(System.out);
        }
        else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }
    
    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            tok=new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }
    
    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }
    
    public static void main(String[] args){
        new ProblemB_03().run();
    }
    
    public void run(){
        try{
            long t1=System.currentTimeMillis();
            init();
            solve();
            out.close();
            long t2=System.currentTimeMillis();
            System.err.println("Time = "+(t2-t1));
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }
    
    class Boat implements Comparable<Boat>{
        
        int size;
        int capacity;
        int num;
        
        public Boat(int size, int capacity, int num){
            this.size = size;
            this.capacity = capacity;
            this.num = num;
        }

        @Override
        public int compareTo(Boat b) {
            return capacity - b.capacity;
        }
    }
    
    void solve() throws IOException{
        ArrayList<Boat> unbox = new ArrayList<Boat>();
        ArrayList<Boat> one = new ArrayList<Boat>();
        ArrayList<Boat> two = new ArrayList<Boat>();
        int n = readInt();
        int v = readInt();
        long s = 0;
        for (int i = 0; i < n; i++){
            Boat boat = new Boat(readInt(), readInt(), i + 1);
            if (boat.size == 1){
                unbox.add(boat);
            }else{
                s += boat.capacity;
                two.add(boat);
                v -= 2;
            }
        }
        Collections.sort(unbox);
        Collections.sort(two);
        int twoIndex = 0;
        while (v < 0){
            s -= two.get(twoIndex++).capacity;
            v += 2;
        }
        for (int i = unbox.size() - 1; i >=0 && v > 0; i--){
            if (unbox.get(i).size == 1){
                s += unbox.get(i).capacity;
                one.add(unbox.get(i));
                unbox.remove(i);
                v--;
            }
        }
        Collections.sort(one);
        int index = unbox.size() - 1;
        int twoCount = two.size();
        Boat boat0, boat1, boat2;
        while (index > 0 && twoIndex != twoCount){
            boat1 = unbox.get(index);
            boat0 = two.get(twoIndex); 
            int capacityNew = boat1.capacity - boat0.capacity;
            if (index == 0){
                if (capacityNew > 0){
                    s += capacityNew;
                    index--;
                    twoIndex++;
                    one.add(boat1);
                    v++;
                }else{
                    break;
                }
            }else{
                boat2 = unbox.get(--index);
                capacityNew += boat2.capacity;
                if (capacityNew > 0){
                    index--;
                    twoIndex++;
                    s += capacityNew;
                    one.add(boat1);
                    one.add(boat2);
                }else{
                    break;
                }
            }
        }
        out.println(s);
        for (int i = 0; i < one.size(); i++){
            out.print(one.get(i).num + " ");
        }
        for (int i = twoIndex; i < twoCount; i++){
            out.print(two.get(i).num + " ");
        }
    }       
}