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.*;

public class B implements Runnable {

    private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    private BufferedReader in;
    private PrintWriter out;
    private StringTokenizer tok = new StringTokenizer("");

    private void init() throws FileNotFoundException {
        Locale.setDefault(Locale.US);
        String fileName = "";
        if (ONLINE_JUDGE && fileName.isEmpty()) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            if (fileName.isEmpty()) {
                in = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            } else {
                in = new BufferedReader(new FileReader(fileName + ".in"));
                out = new PrintWriter(fileName + ".out");
            }
        }
    }

    String readString() {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() {
        return Integer.parseInt(readString());
    }

    long readLong() {
        return Long.parseLong(readString());
    }

    double readDouble() {
        return Double.parseDouble(readString());
    }

    int[] readIntArray(int size) {
        int[] a = new int[size];
        for (int i = 0; i < size; i++) {
            a[i] = readInt();
        }
        return a;
    }

    public static void main(String[] args) {
        //new Thread(null, new _Solution(), "", 128 * (1L << 20)).start();
        new B().run();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    @Override
    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            init();
            solve();
            out.close();
            time();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    private void solve() {
        int n = readInt();
        int v = readInt();

        class Boat {
            int p, index;

            public Boat(int p, int index) {
                this.p = p;
                this.index = index;
            }
        }

        List<Boat> one = new ArrayList<>();
        List<Boat> two = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int type = readInt();
            if (type == 1) {
                one.add(new Boat(readInt(), i + 1));
            } else {
                two.add(new Boat(readInt(), i + 1));
            }
        }

        Comparator<Boat> comparator = new Comparator<Boat>() {
            @Override
            public int compare(Boat o1, Boat o2) {
                return -Integer.compare(o1.p, o2.p);
            }
        };

        Collections.sort(one, comparator);
        Collections.sort(two, comparator);

        long[] prefixTwo = new long[two.size()];
        for (int i = 0; i < two.size(); i++) {
            if (i > 0) {
                prefixTwo[i] = prefixTwo[i - 1];
            }
            prefixTwo[i] += two.get(i).p;
        }

        long answer = 0;
        int oneCount = 0;
        int twoCount = 0;

        long curValue = 0;

        for (int curOneCount = 0; curOneCount <= one.size(); curOneCount++) {
            if (v < curOneCount) {
                break;
            }
            int curTwoCount = Math.min(two.size(), Math.max(0, (v - curOneCount) / 2));
            if (answer < (curTwoCount == 0 ? 0 : prefixTwo[curTwoCount - 1]) + curValue) {
                answer = (curTwoCount == 0 ? 0 : prefixTwo[curTwoCount - 1]) + curValue;
                oneCount = curOneCount;
                twoCount = curTwoCount;
            }
            if (curOneCount < one.size()) {
                curValue += one.get(curOneCount).p;
            }
        }

        out.println(answer);
        for (int i = 0; i < oneCount; i++) {
            out.print(one.get(i).index + " ");
        }
        for (int i = 0; i < twoCount; i++) {
            out.print(two.get(i).index + " ");
        }
    }
}