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:
//package codeforces.ru.betaround3;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

/**
 * Created by IntelliJ IDEA.
 * User: Jamshed
 * Date: 4/3/12
 * Time: 8:55 AM
 */
public class ProblemB implements Runnable {

    public static void main(String arguments[]) {
        new Thread(new ProblemB()).start();
    }

    Scanner scanner;

    public void run() {
        scanner = new Scanner(System.in);

        solve();

        scanner.close();
    }

    private class Ship implements Comparable<Ship> {
        private int type;
        private int capacity;
        private int order;

        public int getType() {
            return type;
        }

        public void setType(int type) {
            this.type = type;
        }

        public int getCapacity() {
            return capacity;
        }

        public void setCapacity(int capacity) {
            this.capacity = capacity;
        }


        public int compareTo(Ship o) {
            if(o.capacity > capacity) return -1;
            if(o.capacity < capacity) return 1;
            return 0;
        }

        public int getOrder() {
            return order;
        }

        public void setOrder(int order) {
            this.order = order;
        }
    }

    private void solve() {
        int n = scanner.nextInt();
        long m = scanner.nextLong();

        ArrayList<Ship> kayaks = new ArrayList<Ship>();
        ArrayList<Ship> catamarans = new ArrayList<Ship>();

        for(int i = 0; i < n; i++) {
            Ship ship = new Ship();

            ship.setType(scanner.nextInt());
            ship.setCapacity(scanner.nextInt());
            ship.setOrder(i + 1);

            if(ship.getType() == 1) {
                kayaks.add(ship);
            } else {
                catamarans.add(ship);
            }
        }

        Collections.sort(kayaks);
        Collections.sort(catamarans);

        long kMas[] = new long[kayaks.size() + 1];

        if(kayaks.size() > 0) {
            kMas[1] = kayaks.get(kayaks.size() - 1).getCapacity();
            for(int i = kayaks.size() - 2, j = 2; i >= 0; i--, j++) {
                kMas[j] = kMas[j - 1] + kayaks.get(i).getCapacity();
            }
        }

        long cMas[] = new long[catamarans.size() + 1];

        if(catamarans.size() > 0) {
            cMas[1] = catamarans.get(catamarans.size() - 1).getCapacity();

            for(int i = catamarans.size() - 2, j = 2; i >= 0; i--, j++) {
                cMas[j] = cMas[j - 1] + catamarans.get(i).getCapacity();
            }
        }

        //System.out.println("cMas size = " + cMas.length);
        //System.out.println("kMas size = " + kMas.length);

        long a = 0; // kayaks size
        long b = 0; // catamarans size
        long max = 0;

        for(long i = 0, j = 0; i <= catamarans.size(); i++) {
            //j = m - 2 * i;
            j = Math.min(kMas.length - 1, m - 2 * i);
            if(j < 0) continue;

            //System.out.println("i = " + (i) + ", j = " + j);
            //System.out.println("kMas[j] = "  + kMas[j]);
            //System.out.println("cMas[i] = "  + cMas[i]);

            if(2 * i + j <= m) {
                if(cMas.length > i && kMas.length > j) {
                    long temp = kMas[((int) j)] + cMas[((int) i)];
                    if(temp > max) {
                        max = temp;
                        a = j;
                        b = i;
                    }
                }
            }
        }

        System.out.println(max);

        //System.out.println("a = " + a + ", b = " + b);

        if(kayaks.size() > 0) {
            for(int i = kayaks.size() - 1; i > kayaks.size() - 1 - a; i--) {
                System.out.print(kayaks.get(i).getOrder() + " ");
            }
        }

        if(catamarans.size() > 0) {
            for(int i = catamarans.size() - 1; i > catamarans.size() - 1 - b; i--) {
                //System.out.println("i = " + i);
                System.out.print(catamarans.get(i).getOrder() + " ");
            }
        }

        //for(Ship ship: result) {
        //    System.out.print(ship.getOrder() + " ");
        //}
    }
}