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:
/*******************************************************************
My love has gone away,
quietly after a hundered days.
This is what's she has always said she won't stay
for more than what she can repay.

I can still hear her say there
that I'm not hearing tender play
The day she let me kiss her was a display,
of love to those who she betray.

How can I put someone to the test,
when I thought I got the best.
Untill the taste of bitterness then I regret
but still that I won't detest,
the love I can't forget,
like someone who has left.

How can i leave someone for the rest
when i'm alone facing the best
Untill they take some try to reason i regret
But still that i won't detest
who i can never forget
like someone i once met .. 
 ******************************************************************/
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.List;

public class B3 {
	public static void main(String[] args) {
		input();
		solve();
	}

	static void solve() {

		StringBuilder strRes = new StringBuilder();
		long res = 0;
		end = s2;
		if (v > sumType) {
			res = sum;
			for (int i = 0; i < n; i++) {
				strRes.append(vehicles[i].pos + " ");
			}
		} else {
			Arrays.sort(vehicles, new Comparator<vehicle>() {

				@Override
				public int compare(vehicle o1, vehicle o2) {
					if (o1.type == o2.type) {
						return Integer.compare(o2.value, o1.value);
					}
					return Integer.compare(o1.type, o2.type);
				}
			});

			while ((v > 1 && (s1 < end || s2 < n)) || (v == 1 && s1 < end)) {
				if ((v == 1 && s1 < end)) {
					strRes.append(vehicles[s1].pos + " ");
					res += vehicles[s1].value;
					v--;
					s1++;
				} else {
					if ((s1 + 1 < end && s2 < n && vehicles[s2].value > vehicles[s1].value
							+ vehicles[s1 + 1].value)
							|| (s1 == end - 1 && s2 < n && vehicles[s2].value > vehicles[s1].value)) {
						strRes.append(vehicles[s2].pos + " ");
						res += vehicles[s2].value;
						v -= 2;
						s2++;
					} else {
						if (s1 < end) {
							strRes.append(vehicles[s1].pos + " ");
							res += vehicles[s1].value;
							v--;
							s1++;
						}
					}
				}
			}
		}
		System.out.println(res);
		System.out.println(strRes);
	}

	/************************************************************************************/
	static int n;
	static int v;
	static vehicle[] vehicles;
	static int s1 = 0;
	static int s2 = 0;
	static int end = 0;
	static int sum = 0;
	static int sumType = 0;

	static void input() {
		n = nextInt();
		v = nextInt();
		vehicles = new vehicle[n];
		for (int i = 0; i < n; i++) {
			vehicle tmp = new vehicle();
			tmp.type = nextInt();
			tmp.value = nextInt();
			tmp.pos = i + 1;
			if (tmp.type == 1) {
				s2++;
			}
			vehicles[i] = tmp;
			sum += tmp.value;
			sumType += tmp.type;
		}
	}

	/************************************************************************************/
	static InputStream is = System.in;
	static private byte[] buffer = new byte[1024];
	static private int lenbuf = 0, ptrbuf = 0;

	static private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(buffer);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return buffer[ptrbuf++];
	}

	static private boolean isSpace(int c) {
		return !(c >= 33 && c <= 126);
	}

	static private int read() {
		int b;
		while ((b = readByte()) != -1 && isSpace(b))
			;
		return b;
	}

	static private double nextDouble() {
		return Double.parseDouble(nextString());
	}

	static private char nextChar() {
		return (char) read();
	}

	static private String nextString() {
		int b = read();
		StringBuilder sb = new StringBuilder();
		while (!(isSpace(b))) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	static private char[] nextString(int n) {
		char[] buf = new char[n];
		int b = read(), p = 0;
		while (p < n && !(isSpace(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	static private int nextInt() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	static private long nextLong() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	static private int[] nextAi(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	static private Integer[] nextAi1(int n) {
		Integer[] a = new Integer[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

}

class vehicle {
	int pos;
	int type;
	int value;
}