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.*;
import static java.util.Arrays.fill;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.sort;

public class Main {
    public static void main(String[] args) throws IOException {
        try {
            if (new File("input.txt").exists()) {
                System.setIn(new FileInputStream("input.txt"));
            }
        } catch (SecurityException e) {
        }
        
        new Main().run();
    }

    BufferedReader in;
    PrintWriter out;
    StringTokenizer st = new StringTokenizer("");
    
    void run() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        
        int n = nextInt();
        int maxW = nextInt();
        
        int n1 = 0;
        int n2 = 0;
        
        Pair[] p1 = new Pair [n];
        Pair[] p2 = new Pair [n];
        
        for (int i = 0; i < n; i++) {
            if (nextInt() == 1) {
                p1[n1++] = new Pair(1, nextInt(), i);
            } else {
                p2[n2++] = new Pair(2, nextInt(), i);
            }
        }
        
        sort(p1, 0, n1);
        sort(p2, 0, n2);

        long[] pv = new long [n1 + 1];
        
        for (int i = 1; i <= n1; i++) {
            pv[i] = pv[i - 1] + p1[i - 1].v;
        }
        
        long cv = 0;
        long best = 0;
        int bestN = 0;
        
        for (int c2 = 0; c2 <= n2; c2++) {
            int c1 = min(n1, maxW - 2 * c2);
            
            if (c1 >= 0) {
                long cur = cv + pv[c1];
                
                if (best < cur) {
                    best = cur;
                    bestN = c2;
                }
            } else {
                break;
            }
            
            if (c2 != n2) {
                cv += p2[c2].v;
            }
        }
        
        out.println(best);
        
        int[] ans = new int [n];
        int asz = 0;
        
        for (int i = 0; i < bestN; i++) {
            ans[asz++] = p2[i].n + 1;
        }
        
        int c1 = min(n1, maxW - 2 * bestN);
        
        for (int i = 0; i < c1; i++) {
            ans[asz++] = p1[i].n + 1;
        }
        
        if (asz > 0) {
            sort(ans, 0, asz);
            out.print(ans[0]);
            
            for (int i = 1; i < asz; i++) {
                out.print(" " + ans[i]);
            }
            
            out.println();
        }
        
        out.close();
    }
    
    class Pair implements Comparable<Pair> {
        int w, v, n;
        
        Pair(int ww, int vv, int nn) {
            w = ww;
            v = vv;
            n = nn;
        }

        @Override
        public int compareTo(Pair o) {
            return o.v - v;
        }
    }
    
    String nextToken() throws IOException {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        
        return st.nextToken();
    }
    
    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    
    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    
    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
    
    String nextLine() throws IOException {
        st = new StringTokenizer("");
        return in.readLine();
    }
    
    boolean EOF() throws IOException {
        while (!st.hasMoreTokens()) {
            String s = in.readLine();
            
            if (s == null) {
                return true;
            }
            
            st = new StringTokenizer(s);
        }
        
        return false;
    }
}