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

public class B3 {
	
	public static void main(String args[]) throws Exception {

		InputReader reader = new InputReader(System.in);
		// when current capacity is 2, I need special care

		int n = reader.I();
		int v = reader.I();
		ArrayList<Pair<Integer, Integer>> sin = new ArrayList<>();
		ArrayList<Pair<Integer, Integer>> dou = new ArrayList<>();
		int prefixDou[] = new int[100001];
		int prefixSin[] = new int[100001];
		for(int i=0;i<n;i++) {
			int vol = reader.I();
			int cap = reader.I();
			if(vol == 1) {
				sin.add(new Pair<>(cap, i));
			} else {
				dou.add(new Pair<>(cap, i));
			}
		}
		
		ArrayList<Integer> result = new ArrayList<>();
		Comparator<Pair<Integer, Integer>> comp = (p1, p2) -> {
			if(p1.getKey() == p2.getKey()) {
				return p1.getValue() - p2.getValue();
			}
			return p1.getKey() - p2.getKey();
		};
		Collections.sort(sin, comp);
		Collections.sort(dou, comp);
		Collections.reverse(sin);
		Collections.reverse(dou);
		
		for(int i=0;i<sin.size();i++) {
			int cap = sin.get(i).getKey();
			prefixSin[i+1] = prefixSin[i]+cap;
		}
		
		for(int i=0;i<dou.size();i++) {
			int cap = dou.get(i).getKey();
			prefixDou[i+1] = prefixDou[i]+cap;
		}
		
		int sol = -1;
		int howmD = 0;
		for(int i=0;i<=dou.size() && i*2 <= v;i++) {
			int rem = v-i*2;
			if(rem > sin.size()) rem = sin.size();
			int totalCap = prefixDou[i]+prefixSin[rem];
			//System.out.println(i + " " + totalCap);
			if(totalCap > sol) {
				sol = totalCap;
				howmD = i;
			}
		}
		
		
		PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		
		out.println(sol);
		out.flush();
		for(int i=0;i<howmD;i++) {
			out.println(dou.get(i).getValue()+1);
		}
		for(int i=0;i<sin.size() && i<v-howmD*2;i++) {
			out.println(sin.get(i).getValue()+1);
		}
		out.close();
	}
        
	

	static BufferedReader br;
    static long M = (long) 1e9 + 7;

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int I() {
            return Integer.parseInt(next());
        }

    }
    
    static class Pair<T, V> {
		T a;
		V b;
		
		public Pair(T a, V b) {
			this.a = a;
			this.b = b;
		}
		T getKey() {
			return a;
		}
		V getValue() {
			return b;
		}
	}
}