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 Lorry2 {
	
	static class vehicle {
		int num,type,cap;
		float eff;
		;
	}
	static Comparator<vehicle> comp1 = new Comparator<vehicle>() {
		@Override
		public int compare(vehicle A, vehicle B) {
			if (A.eff > B.eff)
				return -1;
			if(A.eff < B.eff)
				return 1;
			return 0;
		}
	};
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		
		String [] ss = br.readLine().split(" ");
		
		int N = Integer.parseInt(ss[0]);
		int V = Integer.parseInt(ss[1]);
		
		List<vehicle> list1=new ArrayList<vehicle>();
		List<vehicle> list2=new ArrayList<vehicle>();
//		List<vehicle> list3=new ArrayList<vehicle>();
//		List<vehicle> list4=new ArrayList<vehicle>();
		vehicle[] v = new vehicle[N];
		
		for(int i=0; i<N; i++)
		{
			ss = br.readLine().split(" ");
			
			v[i]=new vehicle();
			v[i].type=Integer.parseInt(ss[0]);
			v[i].cap=Integer.parseInt(ss[1]);
			v[i].num=i+1;
			v[i].eff=((float)v[i].cap)/((float)v[i].type);
			//pw.println(v[i].eff);
		}
		
		Arrays.sort(v, comp1);
		
		
//		pw.println(v[0].eff);
//		pw.println(v[1].eff);
//		pw.println(v[2].eff);
//		pw.println(v[3].eff);
//		pw.println(v[4].eff);
//		pw.println(v[5].eff);
//		pw.println(v[6].eff);
		
		int j=0;
		String optset=new String();
		int optvalue=0;
		
		while(V>1 && j<v.length)
		{
			if(v[j].type==1)
				list1.add(v[j]);
			else
				list2.add(v[j]);
			optvalue+=v[j].cap;
			//pw.println(optvalue);
			V-=v[j].type;
			j++;
		}
		
		vehicle last1= new vehicle();
		vehicle last2= new vehicle();
		
		for(int k=j;k<v.length;k++)
		{   
			if(v[k].type==1 && last1.type!=1)
				{last1=v[k];k=j;}
			if(v[k].type==2 && last2.type!=2)
			    {last2=v[k];k=j;}
			if(last1.type==1 && last2.type==2)
				break;
		}
		//pw.println(last1.type==1);
		//pw.println(last2.num);
		if(V==0)
		{
//			for(int i=0;i<list1.size();i++)
//			{
//				optset = optset + list1.get(i).num + " ";
//			}
//			for(int i=0;i<list2.size();i++)
//			{
//				optset = optset + list2.get(i).num + " ";
//			}
			pw.println(optvalue);
			for (int i = 0; i < list1.size(); i++)
				pw.print((list1.get(i).num) + " ");
			for (int i = 0; i < list2.size(); i++)
				pw.print((list2.get(i).num) + " ");
		}
		else
		{
			if(list1.isEmpty() && last1.type==1)
			{
				list1.add(last1);
				//pw.println(optvalue);
				optvalue+=last1.cap;
				//pw.println(optvalue);
			}else
			if(list1.isEmpty() && last1.type!=1)
			{
				
			}else
			
			if(!list1.isEmpty() && last1.type!=1 && last2.type==2)
			{
				if(list1.get(list1.size()-1).cap<last2.cap)
				{
					optvalue=optvalue-list1.get(list1.size()-1).cap;
					list1.remove(list1.size()-1);
					list2.add(last2);
					optvalue+=last2.cap;
				}
				else
				{
					
				}
			}else
			
			if(!list1.isEmpty() && last1.type==1 && last2.type!=2)
			{
				list1.add(last1);
				optvalue+=last1.cap;
			}else
			//pw.println(!list1.isEmpty());
			if(!list1.isEmpty() && last1.type==1 && last2.type==2)
			{
				if(last2.cap>last1.cap+list1.get(list1.size()-1).cap)
				{
					optvalue=optvalue-list1.get(list1.size()-1).cap;
					list1.remove(list1.size()-1);
					list2.add(last2);
					optvalue+=last2.cap;
				}
				else
				{
					list1.add(last1);
					optvalue+=last1.cap;
				}
			}
			
			pw.println(optvalue);
			for (int i = 0; i < list1.size(); i++)
				pw.print((list1.get(i).num) + " ");
			for (int i = 0; i < list2.size(); i++)
				pw.print((list2.get(i).num) + " ");
//			for(int i=0;i<list1.size();i++)
//			{
//				optset = optset + list1.get(i).num + " ";
//			}
//			for(int i=0;i<list2.size();i++)
//			{
//				optset = optset + list2.get(i).num + " ";
//			}
		}
		
		
//		pw.println(optvalue);
//        pw.println(optset);
		pw.close();
	}

}