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.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.StringTokenizer;
	
	public class template {
		public static void main(String[] args) throws Exception {
			FastScanner sc = new FastScanner(System.in);
			int N = sc.nextInt();
			int V = sc.nextInt();
			LinkedList<ppl> one = new LinkedList<ppl>();
			LinkedList<ppl> two = new LinkedList<ppl>();
			for(int a=0;a<N;a++){
				int c = sc.nextInt();
				if(c == 1){
					one.add(new ppl(sc.nextInt(),a+1));
				}
				else two.add(new ppl(sc.nextInt(),a+1));
			}
			ppl[] a1 = new ppl[one.size()];
			ppl[] a2= new ppl[two.size()];
			Collections.sort(one);
			Collections.sort(two);
			if(!one.isEmpty()){
				a1[0]=new ppl(one.peek().cap,one.pop().index);
			}
			if(!two.isEmpty()){
				a2[0]=new ppl(two.peek().cap,two.pop().index);
			}
			for(int a=1;a<a1.length;a++){
				a1[a]=new ppl(one.peek().cap+a1[a-1].cap,one.poll().index);
			}
			for(int a=1;a<a2.length;a++){
				a2[a]=new ppl(two.peek().cap+a2[a-1].cap,two.poll().index);
			}
			int besta1 =-1;
			int besta2 =-1;
			long bestc=0;
			for(int a=0;a<=V;a+=2){
				long TC = 0;
				int t2 = (a/2)-1;
				if(t2>=a2.length){
					break;
				}
				
				int t1 = V-a;
				t1--;
				if(t1>=a1.length)t1=a1.length-1;
				
	
					if(t1!=-1)TC+=a1[t1].cap;
			
					if(t2!=-1)TC+=a2[t2].cap;
				if(TC>bestc){
					bestc=TC;
					besta1=t1;
					besta2=t2;
				}
			}
		
			System.out.println(bestc);
			StringBuilder SB = new StringBuilder();
			for(int a=0;a<=besta1;a++){
				SB.append(a1[a].index+" ");
			}
			for(int a=0;a<=besta2;a++){
				SB.append(a2[a].index+" ");
			}
			System.out.println(SB);
			
		}
		static class ppl implements Comparable<ppl>{
			int index;
			int cap;	
			ppl(int c, int s){
				this.index = s;
				this.cap = c;
			}
			public int compareTo(ppl o) {
				return o.cap-this.cap;
			}
		}
	
		static class FastScanner {
			BufferedReader br;
			StringTokenizer st;
	
			public FastScanner(InputStream in) throws Exception {
				br = new BufferedReader(new InputStreamReader(in));
				st = new StringTokenizer(br.readLine().trim());
			}
			
	
			public int numTokens() throws Exception {
				if (!st.hasMoreTokens()) {
					st = new StringTokenizer(br.readLine().trim());
					return numTokens();
				}
				return st.countTokens();
			}
	
			public String next() throws Exception {
				if (!st.hasMoreTokens()) {
					st = new StringTokenizer(br.readLine().trim());
					return next();
				}
				return st.nextToken();
			}
	
			public double nextDouble() throws Exception {
				return Double.parseDouble(next());
			}
	
			public float nextFloat() throws Exception {
				return Float.parseFloat(next());
			}
	
			public long nextLong() throws Exception {
				return Long.parseLong(next());
			}
	
			public int nextInt() throws Exception {
				return Integer.parseInt(next());
			}
	
			public String nextLine() throws Exception {
				return br.readLine().trim();
			}
		}
	
	}