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 B0003_Lorry {
	
	static class Kayak implements Comparable<Kayak> {
		int index;
		int capacity;
		
		public Kayak(int i, int c) {
			index = i;
			capacity = c;
		}
		
		public int compareTo(Kayak k) {
			return Integer.compare(capacity, k.capacity);
		}
	}
	
	static class Catamaran implements Comparable<Catamaran> {
		int index;
		int capacity;
		
		public Catamaran(int i, int c) {
			index = i;
			capacity = c;
		}
		
		public int compareTo(Catamaran c) {
			return Integer.compare(capacity, c.capacity);
		}
	}
	
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader();
		int n = in.nextInt();
		int v = in.nextInt();
		
		ArrayList<Kayak> kayaks = new ArrayList<>();
		ArrayList<Catamaran> catamarans = new ArrayList<>();
		for (int i=1; i<=n; i++) {
			if (in.nextInt() == 1) {
				kayaks.add(new Kayak(i, in.nextInt()));
			}
			else {
				catamarans.add(new Catamaran(i, in.nextInt()));
			}
		}
		
		Collections.sort(kayaks);
		Collections.sort(catamarans);
		int kIndex = kayaks.size() - 1;
		int cIndex = catamarans.size() - 1;
		
		StringBuffer sb = new StringBuffer();
		long totalCapacity = 0;
		if (v % 2 == 1 && kIndex >= 0) {
			Kayak k = kayaks.get(kIndex--);
			totalCapacity += k.capacity;
			sb.append(k.index + " ");
			--v;
		}
		while (v > 1) {
			if (cIndex == -1) {
				while (v > 0 && kIndex > -1) {
					Kayak k = kayaks.get(kIndex--);
					totalCapacity += k.capacity;
					sb.append(k.index + " ");
				}
				break;
			}
			if (kIndex == -1) {
				while (v > 1 && cIndex > -1) {
					Catamaran c = catamarans.get(cIndex--);
					totalCapacity += c.capacity;
					sb.append(c.index + " ");
				}
				break;
			}
			if (kIndex == 0) {
				if (kayaks.get(kIndex).capacity > catamarans.get(cIndex).capacity) {
					Kayak k = kayaks.get(kIndex--);
					totalCapacity += k.capacity;
					sb.append(k.index + " ");
					--v;
				}
				else {
					Catamaran c = catamarans.get(cIndex--);
					totalCapacity += c.capacity;
					sb.append(c.index + " ");
					v -= 2;
				}
			}
			else {
				Kayak k1 = kayaks.get(kIndex);
				Kayak k2 = kayaks.get(kIndex - 1);
				Catamaran c1 = catamarans.get(cIndex);
				if (c1.capacity >= k1.capacity + k2.capacity) {
					totalCapacity += c1.capacity;
					sb.append(c1.index + " ");
					--cIndex;
				}
				else {
					totalCapacity += k1.capacity + k2.capacity;
					sb.append(k1.index + " " + k2.index + " ");
					kIndex -= 2;
				}
				v -= 2;
			}
		}
		
		if (v == 1 && kayaks.size() > 0) {
			Kayak k = kayaks.get(kIndex);
			totalCapacity += k.capacity;
			sb.append(k.index + " ");
		}
		
		System.out.println(totalCapacity);
		System.out.println(sb);
	}
	
	static class InputReader {
		public BufferedReader br;
		public StringTokenizer st;
		
		public InputReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = null;
		}
		
		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}