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 cf_3b;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		String[] input = in.readLine().split("\\s");
		
		int n = Integer.parseInt(input[0]);
		int maxVol = Integer.parseInt(input[1]);
		
		ArrayList<Boat> kayak = new ArrayList<Boat>();
		ArrayList<Boat> catam = new ArrayList<Boat>();
		
		int cSize = 0;
		int kSize = 0;
		
		for(int i = 0; i < n; i++){
			String[] line = in.readLine().split("\\s");
			int boatSize = Integer.parseInt(line[0]);
			int capacity = Integer.parseInt(line[1]);
			
			if(boatSize == 1){
				kayak.add(new Boat(capacity, i));
				kSize++;
			}
			else{
				catam.add(new Boat(capacity, i));
				cSize++;
			}
		}
		
		Collections.sort(kayak);
		Collections.sort(catam);
		
		ArrayList<Integer> indexes = new ArrayList<Integer>();
		
		int maxCap = 0;
		int k = 0;
		int c = 0;
		
		for(int i = maxVol; i > 0;){
			if(i > 1){
				int temp = 0;
				if(k < kSize && c < cSize){
					int next = k + 1;
					if(next < kSize)
						temp = kayak.get(k).capacity + kayak.get(next).capacity;
					else
						temp = kayak.get(k).capacity;
					if(temp > catam.get(c).capacity){
						maxCap += kayak.get(k).capacity;
						indexes.add(kayak.get(k).index + 1);
						i--;
						k++;
					}
					else{
						maxCap += catam.get(c).capacity;
						indexes.add(catam.get(c).index + 1);
						i -= 2;
						c++;
					}					
				}		
				else if(k < kSize){
					maxCap += kayak.get(k).capacity;
					indexes.add(kayak.get(k).index + 1);
					i--;
					k++;
				}
				else if(c < cSize){
					maxCap += catam.get(c).capacity;
					indexes.add(catam.get(c).index + 1);
					i--;
					c++;
				}
				else
					break;
			}
			else
			{
				if(k < kSize){
					maxCap += kayak.get(k).capacity;
					indexes.add(kayak.get(k).index + 1);
					i--;
					k++;
				}
				else
					break;
			}
		}
	
		
		System.out.println(maxCap);
		StringBuffer index = new StringBuffer();
		for(int ind: indexes)
			index.append(ind + " ");
		
		System.out.println(index);
		
	}
	
	
	public static class Boat implements Comparable<Boat>{
		int capacity, index;
		
		Boat(int c, int i){
			this.capacity = c;
			this.index = i;
		}

		@Override
		public int compareTo(Boat b) {
			return b.capacity - this.capacity;
		}
	}
}