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.util.*;
import java.io.*;

public class B0003 {

    public static void main(String args[]) throws Exception {
        new B0003();
    }

    B0003() throws Exception {
        PandaScanner sc = null;
        PrintWriter out = null;
        try {
            sc = new PandaScanner(System.in);
            out = new PrintWriter(System.out);
        } catch (Exception ignored) {
        }

        int n = sc.nextInt();
        int v = sc.nextInt();
        PriorityQueue<Ship> type[] = new PriorityQueue[] {new PriorityQueue<Ship>(), new PriorityQueue<Ship>()};

        ArrayDeque<Integer> ships = new ArrayDeque<Integer>();
        ArrayDeque<Integer> front = new ArrayDeque<Integer>();

        for (int i = 1; i <= n; i++) {
            int t = sc.nextInt();
            int vol = sc.nextInt();
            type[t - 1].add(new Ship(i, vol));
        }

        int curr = 0;
        PriorityQueue<Integer> undo = new PriorityQueue<Integer>();
        for (int i = 1; i > -1; i--) {
            while (v > i && !type[i].isEmpty()) {
                if (i == 1) {
                    ships.addFirst(type[i].peek().i);
                    undo.add(type[i].peek().v);
                }
                else {
                    ships.addLast(type[i].peek().i);
                }
                curr += type[i].poll().v;
                v -= (i + 1);
            }
        }

        int max = curr;
        while (!undo.isEmpty() && !type[0].isEmpty()) {
            curr -= undo.poll();
            int s = Math.min(2, type[0].size());
            for (int i = 0; i < s; i++) {
                front.add(type[0].peek().i);
                curr += type[0].poll().v;
            }
            if (max < curr) {
                max = curr;
                int poll = (front.size() + 1) >> 1;
                for (int i = 0; i < poll; i++) {
                    ships.removeFirst();
                }
                ships.addAll(front);
                front.clear();
            }
        }

        out.println(max);
        for (Integer i: ships) {
            out.print(i + " ");
        }
        out.println();

        out.close();
        System.exit(0);
    }

    public class Ship implements Comparable<Ship> {
        int i;
        int v;
        public Ship(int i, int v) {
            this.i = i;
            this.v = v;
        }
        public int compareTo(Ship o) {
            if (o.v == v) {
                return Integer.compare(o.i, i);
            }
            return Integer.compare(o.v, v);
        }
    }

    //The PandaScanner class, for Panda fast scanning!
    public class PandaScanner {
        BufferedReader br;
        StringTokenizer st;
        InputStream in;

        PandaScanner(InputStream in) throws Exception {
            br = new BufferedReader(new InputStreamReader(this.in = in));
        }

        public String next() throws Exception {
            if (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine().trim());
                return next();
            }
            return st.nextToken();
        }

        public boolean hasNext() throws Exception {
            return (st != null && st.hasMoreTokens()) || in.available() > 0;
        }

        public long nextLong() throws Exception {
            return Long.parseLong(next());
        }

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