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 A {
	public static void main (String[] args) { new A(); }

	public A() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		ArrayList<Type> ones = new ArrayList<>();
		ArrayList<Type> twos = new ArrayList<>();
		int n = fs.nextInt(), v = fs.nextInt();
		for(int i = 0; i < n; i++) {
			int x = fs.nextInt();
			int y = fs.nextInt();
			if(x == 1) ones.add(new Type(y, i));
			else twos.add(new Type(y, i));
		}
		
		long res = 0;
		
		Collections.sort(ones);
		Collections.sort(twos);
		long[] pref = new long[ones.size()];
		for(int i = 0; i < ones.size(); i++) {
			pref[i] = ones.get(i).vol;
			if(i > 0) pref[i] += pref[i-1];
		}
		
		int ptr = -1;
		int spaceLeft = v;
		long curSum = 0;
		int PtrAns = -1;
		while(ptr < twos.size()) {
			if(ptr >= 0) {
				spaceLeft -= 2;
				curSum += twos.get(ptr).vol;
			}
			if(spaceLeft >= 0) {
				long tempRes = curSum;
				int idx = Math.min(ones.size()-1, spaceLeft-1);
				if(idx >= 0) tempRes += pref[idx];
				if(tempRes > res) {
					res = tempRes;
					PtrAns = ptr;
				}
			}
			
			ptr++;
		}
		
		out.println(res);
		for(int i = 0; i <= PtrAns; i++) {
			out.print(twos.get(i).id+1 + " ");
		}
		spaceLeft = v-2*(PtrAns+1);
		int idx = Math.min(ones.size()-1, spaceLeft-1);
		while(idx >= 0) {
			out.print(ones.get(idx).id+1 + " ");
			idx--;
		}
		out.println();
		
		out.close();
	}

	class Type implements Comparable<Type> {
		int vol, id;
		Type(int a, int b) {
			vol = a; id = b;
		}
		public int compareTo(Type t) {
			return Integer.compare(t.vol, vol);
		}
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
		
		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}
		
	}

}