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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

public class B003 {

    private static class P implements Comparable<P> {
        public int type, cap, index;
        public double ratio;

        public P(int type, int cap, double ratio, int index) {
            this.type = type;
            this.cap = cap;
            this.ratio = ratio;
            this.index = index;
        }

        public int compareTo(P d) {
            return Double.compare(this.ratio, d.ratio);
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int v = in.nextInt();
            int type, cap;
            double ratio;
            int sum = 0;
            StringBuffer s = new StringBuffer();
            List<P> p = new ArrayList<P>();

            for (int i = 0; i < n; i++) {
                type = in.nextInt();
                cap = in.nextInt();
                ratio = (1.0 * cap) / type;
                p.add(new P(type, cap, ratio, i + 1));
            }
            Collections.sort(p, Collections.reverseOrder());
            boolean flag = false;

            //get ready cause the logic gets crazy from now on      
            for (int i = 0; i < p.size(); i++) {
                if (p.get(i).type > v) {
                    continue;
                } else {

                    //this thing just makes sure that the last element won't have a space after it
                    if (!flag) {
                        flag = true;
                    } else {
                        s.append(" ");
                    }
                    // problems only appear when it's type 1
                    if (p.get(i).type == 1) {
                        //if there's a 1 m room then add type 1
                        if (v % 2 == 1) {
                            sum += p.get(i).cap;
                            v -= p.get(i).type;
                            s.append(p.get(i).index);

                            //there might be a room for a better type 2
                        } else {

                            // if it's the last boat just add it
                            if (i == p.size() - 1) {
                                sum += p.get(i).cap;
                                v -= p.get(i).type;
                                s.append(p.get(i).index);

                                //if the next type is 1 then don't worry, just add the current boat
                                // and the next boat will be added in the next iteration
                                // and they will together fill the 2m with the best ratio possible
                            } else if (p.get(i + 1).type == 1) {
                                sum += p.get(i).cap;
                                v -= p.get(i).type;
                                s.append(p.get(i).index);

                            }

                            // we will get to this condition only if
                            // the remaining room is divisible by 2
                            // and we can't find a couple of adequate type 1 boats
                            // and this isn't the last boat
                            // so we will compare the type 1 boat with the next type 2 boat
                            // if we find that it's better than the type 1 boat
                            // we will add it then remove it from the list
                            // then the i will be reset to the previous boat so it's not skipped
                            else {
                                if (p.get(i).cap > p.get(i + 1).cap) {
                                    sum += p.get(i).cap;
                                    v -= p.get(i).type;
                                    s.append(p.get(i).index);
                                } else {
                                    sum += p.get(i + 1).cap;
                                    v -= p.get(i + 1).type;
                                    s.append(p.get(i + 1).index);
                                    p.remove(i + 1);
                                    i--;
                                }

                            }
                        }
                    } else {
                        sum += p.get(i).cap;
                        v -= p.get(i).type;
                        s.append(p.get(i).index);

                    }
                }

                if (v == 0) {
                    break;
                }
            }
            System.out.println(sum);
            System.out.println(s);

        }
    }
}