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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Comparator;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author dauom
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    BLorry solver = new BLorry();
    solver.solve(1, in, out);
    out.close();
  }

  static class BLorry {
    public final void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt();
      int v = in.nextInt();
      int[][] k = new int[n][];
      int[][] c = new int[n][];
      int kcnt = 0, ccnt = 0;
      for (int i = 0; i < n; i++) {
        if (in.nextInt() == 1) {
          k[kcnt++] = new int[] {in.nextInt(), i + 1};
        } else {
          c[ccnt++] = new int[] {in.nextInt(), i + 1};
        }
      }
      k = Arrays.copyOf(k, kcnt);
      c = Arrays.copyOf(c, ccnt);
      Arrays.sort(k, Comparators.singletonIntArr);
      Arrays.sort(c, Comparators.singletonIntArr);

      int ans = 0;
      for (; kcnt > 0 && v > 0; v--) {
        ans += k[--kcnt][0];
      }
      for (; ccnt > 0 && v > 1; v -= 2) {
        ans += c[--ccnt][0];
      }
      int bestkcnt = kcnt, bestccnt = ccnt;
      if (ccnt > 0) {
        int nans = ans;
        while ((kcnt + 1 < k.length || (kcnt < k.length && v > 0)) && ccnt > 0) {
          nans += c[--ccnt][0];
          nans -= k[kcnt++][0];
          if (v > 0) {
            v = 0;
          } else {
            nans -= k[kcnt++][0];
          }
          if (nans > ans) {
            ans = nans;
            bestkcnt = kcnt;
            bestccnt = ccnt;
          }
        }
      }

      out.println(ans);
      for (int i = bestkcnt; i < k.length; i++) {
        out.print(k[i][1] + " ");
      }
      for (int i = bestccnt; i < c.length; i++) {
        out.print(c[i][1] + " ");
      }
    }
  }

  static final class InputReader {
    private final InputStream stream;
    private final byte[] buf = new byte[1 << 18];
    private int curChar;
    private int numChars;

    public InputReader() {
      this.stream = System.in;
    }

    public InputReader(final InputStream stream) {
      this.stream = stream;
    }

    private int read() {
      if (this.numChars == -1) {
        throw new UnknownError();
      } else {
        if (this.curChar >= this.numChars) {
          this.curChar = 0;

          try {
            this.numChars = this.stream.read(this.buf);
          } catch (IOException ex) {
            throw new InputMismatchException();
          }

          if (this.numChars <= 0) {
            return -1;
          }
        }

        return this.buf[this.curChar++];
      }
    }

    public final int nextInt() {
      int c;
      for (c = this.read(); isSpaceChar(c); c = this.read()) {}

      byte sgn = 1;
      if (c == 45) { // 45 == '-'
        sgn = -1;
        c = this.read();
      }

      int res = 0;

      while (c >= 48 && c <= 57) { // 48 == '0', 57 == '9'
        res *= 10;
        res += c - 48; // 48 == '0'
        c = this.read();
        if (isSpaceChar(c)) {
          return res * sgn;
        }
      }

      throw new InputMismatchException();
    }

    private static boolean isSpaceChar(final int c) {
      return c == 32 || c == 10 || c == 13 || c == 9
          || c == -1; // 32 == ' ', 10 == '\n', 13 == '\r', 9 == '\t'
    }
  }

  static final class Comparators {
    public static final Comparator<int[]> singletonIntArr = (x, y) -> compare(x[0], y[0]);

    private static final int compare(final int x, final int y) {
      return x < y ? -1 : (x == y ? 0 : 1);
    }
  }
}