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.InputStreamReader;
import java.util.Arrays;

public class Lorry2 {
    public static class veh2 implements Comparable<veh2> {
        int index, type;
        long capacity;

        public veh2(int i, long capacity, int t) {
            this.index = i;
            this.capacity = capacity;
            this.type = t;
        }

        @Override
        public int compareTo(veh2 v1) {
            if (v1.type == type) {
                if (v1.capacity > capacity)
                    return 1;
                else if (v1.capacity == capacity)
                    return 0;
                return -1;

            } else
                return v1.type - type;
        }

        public String toString() {
            return this.type + " - " + this.capacity;
        }

    }

    static veh2[] type1, type2;
    static int v, numOfTwos;
    static long max;

    static void maxVal(int c1) {
        if (c1 * 2 > v)
            return;
        long call = 0;
        if (c1 > type2.length)
            return;
        if (c1 != 0) {
            call = type2[c1 - 1].capacity;
        }
        int n = v - c1 * 2;
        call += maxT1(n);
        if (call > max) {
            max = call;
            numOfTwos = c1;
        }
        maxVal(c1 + 1);
    }

    static long maxT1(int n) {
        if (n <= 0)
            return 0;
        if (n > type1.length)
            n = type1.length;
        return type1[n - 1].capacity;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String l[] = bf.readLine().split(" ");
        int n = Integer.parseInt(l[0]);
        v = Integer.parseInt(l[1]);
        veh2[] boxes = new veh2[n];
        int t2C = 0;
        for (int i = 0; i < n; i++) {
            l = bf.readLine().split(" ");
            int t = Integer.parseInt(l[0]);
            int c = Integer.parseInt(l[1]);
            boxes[i] = new veh2(i + 1, c, t);
            if (t == 2)
                t2C++;
        }
        Arrays.sort(boxes);
        type1 = null;
        type2 = null;
        if (n != t2C)
            type1 = new veh2[n - t2C];
        if (t2C != 0)
            type2 = new veh2[t2C];
        if (type1 != null) {
            type1[0] = boxes[t2C];
            int c = 1;
            for (int i = t2C + 1; i < boxes.length; i++) {
                type1[c] = boxes[i];
                type1[c].capacity += type1[c - 1].capacity;
                c++;
            }
        }
        if (type2 != null) {
            type2[0] = boxes[0];
            for (int i = 1; i < t2C; i++) {
                type2[i] = boxes[i];
                type2[i].capacity += type2[i - 1].capacity;
            }
        }
        if (type2 == null) {
            int len = Math.min(type1.length, v);
            System.out.println(type1[len - 1].capacity);
            for (int i = 0; i < len; i++) {
                System.out.print(type1[i].index + " ");
            }
        } else if (type1 == null) {
            if (v < 2)
                System.out.println(0);
            else {
                int len = Math.min(type2.length, v / 2);
                System.out.println(type2[len - 1].capacity);
                for (int i = 0; i < len; i++) {
                    System.out.print(type2[i].index + " ");
                }
            }
        } else {
            maxVal(0);
            System.out.println(max);
            for (int i = 0; i < numOfTwos && i < type2.length; i++) {
                System.out.println(type2[i].index);
            }
            for (int i = 0; i < v - 2 * numOfTwos && i < type1.length; i++) {
                System.out.println(type1[i].index);
            }
        }
    }
}