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.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
    
	public static void main( String[] args ) throws FileNotFoundException {
    	new CodeForces_3B().doit();
    }
}
class CodeForces_3B {
	InputReader ir;
	Scanner sc;
	PrintStream ps;
	public void doit() throws FileNotFoundException {
		ir = new InputReader( System.in );
		//Scan sn = new Scan( System.in );
		//Scan sn = new Scan( new FileInputStream("1006.in") );
		//sc = new Scanner( System.in );
		ps = System.out;
		//ps = new PrintStream(new FileOutputStream(new File("test")));
		int n = ir.nextInt(), v = ir.nextInt(), op = 0, tp = 0;
		Boat[] one = new Boat[ n ], two = new Boat[ n ];
		for ( int i = 0; i < n; i++ ) {
			int t = ir.nextInt();
			int c = ir.nextInt();
			if ( t == 1 ) one[ op++ ] = new Boat( c, i+1 );
			else if ( t == 2 ) two[ tp++ ] = new Boat( c, i+1 );
		}
		Arrays.sort( one, 0, op );
		Arrays.sort( two, 0, tp );
		int res = 0;
		StringBuffer ans = new StringBuffer();
		while ( v > 0 ) {
			Boat t = new Boat( 0, 0 ), o1 = new Boat( 0, 0 ), o2 = new Boat( 0, 0 );
			if ( tp > 0 ) t = two[ tp-1 ];
			if ( op > 0 ) o1 = one[ op-1 ];
			if ( op > 1 ) o2 = one[ op-2 ];
			if ( t.c > o1.c+o2.c && v >= 2 ) {
				v -= 2;
				res += t.c;
				ans.append( " " + t.id );
				tp--;
			} else {
				if ( o1.id != 0 ) {
					v--;
					res += o1.c;
					ans.append( " " + o1.id );
					op--;
				}
			}
			if ( op == 0 && (tp == 0 || v == 1) ) break;
		}
		ps.println( res );
		if ( res > 0 ) ps.println( ans.toString().substring(1) );
	}
}
class Boat implements Comparable<Boat> {
	int c, id;
	public Boat( int c, int id ) {
		this.c = c;
		this.id = id;
	}
	@Override
	public int compareTo(Boat o) {
		return c - o.c;
	}
	
}
class InputReader {
	private BufferedReader reader;
	private StringTokenizer tokenizer;
	
	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream));
		tokenizer = null;
	}
	public boolean hasNext() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (Exception e) {
				return false;
			}
		}
		return tokenizer.hasMoreTokens();
	}
	public String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong( next() );
	}
	public double nextDouble() {
		return Double.parseDouble( next() );
	}
}
class Scan {
	InputStream inp;
	public Scan(InputStream in) {
		inp = in;
	}
	public String next() {
		StringBuffer res = new StringBuffer();
		try {
			int t = inp.read();
			while ( (t < 'a' || t > 'z') && (t < 'A' || t > 'Z') && ( t < '1' || t < '9') ) t = inp.read();
			while ( ('a' <= t && t <= 'z') || ('A' <= t && t <= 'Z') || ('1' <= t && t <= '9') ) {
				res.append( ((char)t) );
				t = inp.read();
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return res.toString();
	}
	public int nextInt() {
		boolean isN = false;
		int res = 0;
		int t;
		try {
			t = inp.read();
			if (t == -1) return -1;
			while (t != -1 && t != '-' && (t > '9' || t < '0')) t = inp.read();
			if ( t == '-' ) {
				isN = true;
				t = inp.read();
			}
			while (t != -1 && t >= '0' && t <= '9') {
				res = res * 10 + (t - '0');
				t = inp.read();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		if ( isN ) res = -res;
		return res;
	}
	public double nextDouble() {
		double res = 0, Dec = 0.1;
		boolean isN = false, isD = false;
    	int t;
    	try {
    		t = inp.read();
			if ( t == -1 ) return -1;
			while ( t != '-' && t != '.' && (t < '0' || t > '9') ) t = inp.read();
			if ( t == '-' ) {
				isN = true;
				res = 0;
			} else if ( t == '.' ) {
				isD = true;
				res = 0;
			} else res = (double) t - '0';
			if ( !isD ) {
				t = inp.read();
				while ( t >= '0' && t <= '9' ) {
					res = res * 10 + (t - '0');
					t = inp.read();
				}
			}
			if ( t != '.' ) {
				if ( isN ) res = -res;
				return res;
			} else {
				t = inp.read();
				while ( t >= '0' && t <= '9' ) {
					res += Dec * (t - '0');
					Dec *= 0.1;
					t= inp.read();
				}
			}
			if ( isN ) res = -res;
		} catch (IOException e) {
			e.printStackTrace();
		}
    	return res;
    }
}