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.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Lorry {
	
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		
		int v = sc.nextInt();
		
		ArrayList<Point> t1 = new ArrayList<>();
		ArrayList<Point> t2 = new ArrayList<>();
		
		
		HashMap<Integer, Integer> map = new HashMap<>();
		
		for (int i = 0; i < n; i++) {
			int type = sc.nextInt();
			int val = sc.nextInt();
			map.put(i+1, val);
			if(type == 1) t1 .add(new Point(val, i));
			else t2 .add(new Point(val, i));
			
		}
		
		
		Collections.sort(t1, new Comparator<Point>() {

			@Override
			public int compare(Point o1, Point o2) {
				return o2.x - o1.x;
			}
		});
		Collections.sort(t2 ,new Comparator<Point>() {

			@Override
			public int compare(Point o1, Point o2) {
				return o2.x - o1.x;
			}
		});
		
		
//		for (int i = 0; i < t1.size(); i++) {
//			System.out.print("("+t1.get(i).x+","+(t1.get(i).y+1)+") ");
//		}
//		System.out.println();
//		for (int i = 0; i < t2.size(); i++) {
//			System.out.print("("+t2.get(i).x+","+(t2.get(i).y+1)+") ");
//		}
//		System.out.println();
		
		ArrayList<Integer> res = new ArrayList<>();
		int ans = 0;
		
		if(v % 2 == 1 && t1.size() > 0){
			v--;
			ans += t1.get(0).x;
			res.add(t1.remove(0).y+1);
			
		}
		
		int last = -1;
		while(v > 0 && (t1.size() > 0 || t2.size() > 0)){
			if(t1.size() == 0 && v == 1) break;
			
			else if(v == 1){
				v--;
				ans += t1.get(0).x;
				last = t1.remove(0).y+1;
				res.add(last);
			}
			
			else if(t1.size() == 0){
				v-=2;
				ans += t2.get(0).x;
				res.add(t2.remove(0).y+1);
			}
			
			else if(t2.size() == 0){
				v--;
				ans += t1.get(0).x;
				last = t1.remove(0).y+1;
				res.add(last);;
			}
			
			else if(t1.size() == 1){
				if(t1.get(0).x >= t2.get(0).x){
					v--;
					ans += t1.get(0).x;
					last = t1.remove(0).y+1;
					res.add(last);
				}else{
					v-=2;
					ans += t2.get(0).x;
					res.add(t2.remove(0).y+1);
				}
			}
			else {
				if(t1.get(0).x + t1.get(1).x >= t2.get(0).x){
					v-=2;
					ans += t1.get(0).x;
					last = t1.remove(0).y+1;
					res.add(last);
					ans += t1.get(0).x;
					last = t1.remove(0).y+1;
					res.add(last);
				}else{
					v-=2;
					ans += t2.get(0).x;
					res.add(t2.remove(0).y+1);
				}
			}
			
			
//			System.out.println(v);
			
		}
		
		out.println(ans);
		for (int i = 0; i < res.size(); i++) {
			out.print(res.get(i)+" ");
		}
		
		out.flush();
		out.close();
		
		
	}
	
	
	
	static class Scanner 



	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException 
		{
			while (st == null || !st.hasMoreTokens()) 
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}


		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}

		public boolean ready() throws IOException {return br.ready();}



	}

}