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.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.InputMismatchException;


public class CF_B {
	static FastScanner sc = new FastScanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	
	public static void main(String[] args) {
		new CF_B().run();
		out.close();
	}
	
	public void run(){
		int n = sc.nextInt();
		int c = sc.nextInt();
		ArrayList<Ent> one = new ArrayList<>();
		ArrayList<Ent> two = new ArrayList<>();
		for(int i = 0;i<n;i++){
			int type = sc.nextInt();
			int cap = sc.nextInt();
			if(type == 1){
				one.add(new Ent(i+1, cap));
			}else{
				two.add(new Ent(i+1, cap));
			}
		}
		Collections.sort(one);
		Collections.sort(two);
		
		long res = 0;
		int oneCap = 0;
		int twoCap = 0;
		int ans1 = 0;
		int ans2 = 0;
		for(int i = 0;i<one.size();i++)
			oneCap+=one.get(i).cap;
		int oneNum = one.size();
		int twoNum = 0;
		while(oneNum>c){
			oneNum--;
			oneCap-=one.get(oneNum).cap;
		}
		res = oneCap;
		ans1 = oneNum;
		ans2 = twoNum;
		for(twoNum = 1;twoNum*2<=c && twoNum <= two.size();twoNum++){
			twoCap+=two.get(twoNum-1).cap;
			while(oneNum+twoNum*2>c){
				oneNum--;
				oneCap-=one.get(oneNum).cap;
			}
			if(oneCap + twoCap > res){
				res = oneCap + twoCap;
				ans1 = oneNum;
				ans2 = twoNum;
			}
		}
		out.println(res);
		for(int i = 0;i<ans1;i++)
			out.print(one.get(i).index + " ");
		for(int i = 0;i<ans2;i++)
			out.print(two.get(i).index + " ");
	}

	static class FastScanner {
		private final InputStream stream;
	    private final byte[] buf = new byte[8192];
	    private int curChar, snumChars;

	    public FastScanner(InputStream st) {
	      this.stream = st;
	    }

	    //读一个字节
	    public int read() {
	      if (snumChars == -1)
	        throw new InputMismatchException();
	      if (curChar >= snumChars) {
	        curChar = 0;
	        try {
	          snumChars = stream.read(buf);
	        } catch (IOException e) {
	          throw new InputMismatchException();
	        }
	        if (snumChars <= 0)
	          return -1;
	      }
	      return buf[curChar++];
	    }

	    public int nextInt() {
	      int c = read();
	      while (isSpaceChar(c)) {
	        c = read();
	      }
	      int sgn = 1;
	      if (c == '-') {
	        sgn = -1;
	        c = read();
	      }
	      int res = 0;
	      do {
	        res *= 10;
	        res += c - '0';
	        c = read();
	      } while (!isSpaceChar(c));
	      return res * sgn;
	    }

	    public boolean isSpaceChar(int c) {
	      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	    }
	}
}
class Ent implements Comparable<Ent>{
	int index;
	int cap;
	public Ent(int index, int cap) {
		this.index = index;
		this.cap = cap;
	}
	@Override
	public int compareTo(Ent o) {
		return (int) (o.cap-this.cap);
	}
}
//参考的大神Petr的代码
//先把体积是1的全部装进去，然后如果超了，就出来
//然后放体积是2的，从大的开始放，超了就出来体积是1的小的，记录每一种情况的最大值
//输出最大值，最大值就是答案