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.*;
import java.util.concurrent.TimeUnit;

public class e89 implements Runnable{
	
    public static void main(String[] args) {
    	try{
            new Thread(null, new e89(), "process", 1<<26).start();
        }
        catch(Exception e){
            System.out.println(e);
        }
    }
	public void run() {
		FastReader scan = new FastReader();
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
		//PrintWriter out = new PrintWriter("file.out");
		Task solver = new Task();
		//int t = scan.nextInt();
		int t = 1;
		for(int i = 1; i <= t; i++) solver.solve(i, scan, out);
		out.close();
	}

	static class Task {
		static final int inf = Integer.MAX_VALUE;

		public void solve(int testNumber, FastReader sc, PrintWriter out) {
			int N = sc.nextInt();
			int V = sc.nextInt();
			
			PriorityQueue<tup> pq = new PriorityQueue<tup>(new tup());
			for(int i = 1; i <= N; i++) {
				pq.add(new tup(sc.nextInt(), sc.nextInt(), i));
			}
			
			PriorityQueue<Integer> sol = new PriorityQueue<>();
			long cc = 0;
			tup one = null; tup two = null;
			while(V > 0 && pq.size() > 0) {
				if(pq.peek().a == 1)
					one = pq.peek();
				else
					two = pq.peek();
				V -= pq.peek().a;
				cc += pq.peek().b;
				sol.add(pq.poll().c);
			}
			
			int ignore = -1;
			tup nextBestOne = null;
			while(pq.size() > 0) {
				if(pq.peek().a == 1) {
					nextBestOne = pq.peek();
					break;
				}
				pq.poll();
			}
			// if V = -1, see if you can remove a one. Otherwise, remove a two.
			if(V == -1) {
				if(two == null) { // remove a one
					ignore = one.c;
					cc -= one.b;
				} else if(one == null) { // remove a two. see if you can add another one
					ignore = two.c;
					cc -= two.b;
				} else {
					int value = one.b;
					if(nextBestOne != null)
						value += nextBestOne.b;
					if(value > two.b) {
						ignore = two.c;
						cc -= two.b;
						if(nextBestOne != null) {
							cc += nextBestOne.b;
							sol.add(nextBestOne.c);
						}
					} else {
						ignore = one.c;
						cc -= one.b;
					}
				}
			}
			
			out.println(cc);
			while(sol.size() > 0) {
				if(sol.peek() == ignore)
					sol.poll();
				else
					out.println(sol.poll());
			}
		}
	}
	static long binpow(long a, long b, long m) {
		a %= m;
		long res = 1;
		while (b > 0) {
			if ((b & 1) == 1)
				res = res * a % m;
			a = a * a % m;
			b >>= 1;
		}
		return res;
	}
	static void sort(int[] x){
		shuffle(x);
		Arrays.sort(x);
	}
	static void sort(long[] x){
		shuffle(x);
		Arrays.sort(x);
	}
	static class tup implements Comparable<tup>, Comparator<tup>{
		int a, b, c;
		tup(int a,int b, int c){ // a = 1/2, b = cc, c = id
			this.a=a;
			this.b=b;
			this.c = c;
		}
		public tup() {
		}
		@Override
		public int compareTo(tup o){
			return Double.compare(((double)o.b)/o.a, ((double)b)/a);
		}
		@Override
		public int compare(tup o1, tup o2) {
			return Double.compare(((double)o2.b)/o2.a, ((double)o1.b)/o1.a);
		}
		
		@Override
	    public int hashCode() {
			return Objects.hash(a, b);
	    }
 
	    @Override
	    public boolean equals(Object obj) {
	    	if (this == obj)
                return true;
	    	if (obj == null)
                return false;
	    	if (getClass() != obj.getClass())
                return false;
	    	tup other = (tup) obj;
	    	return a==other.a && b==other.b;
	    }
	    
	    @Override
	    public String toString() {
	    	return a + " " + b;
	    }
	}
	
	static void shuffle(int[] a) {
		Random get = new Random();
		for (int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			int temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}

	static void shuffle(long[] a) {
		Random get = new Random();
		for (int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			long temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastReader(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

}