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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
class Vehicle {
 public:
  int p, pos, t;
  Vehicle() {
    p = 0;
    pos = 0;
    t = 0;
  }
};
void merge(Vehicle arr[], int l, int m, int r) {
  int i, j, k, L = m - l + 1, R = r - m;
  Vehicle left[L], right[R];
  for (i = 0; i < L; i++) left[i] = arr[l + i];
  for (i = 0; i < R; i++) right[i] = arr[m + 1 + i];
  i = 0;
  j = 0;
  k = l;
  while (i < L && j < R) {
    if (left[i].p >= right[j].p) {
      arr[k] = left[i];
      i++;
    } else {
      arr[k] = right[j];
      j++;
    }
    k++;
  }
  while (i < L) {
    arr[k] = left[i];
    k++;
    i++;
  }
  while (j < R) {
    arr[k] = right[j];
    k++;
    j++;
  }
}
void merge_sort(Vehicle arr[], int l, int r) {
  if (l < r) {
    int m = l + (r - l) / 2;
    merge_sort(arr, l, m);
    merge_sort(arr, m + 1, r);
    merge(arr, l, m, r);
  }
}
int main() {
  Vehicle kayak[100001], catamaran[100001], first[100001], output[100001];
  int n, v, t, p, i, j, k = 0, c = 0, volume = 0, max = 0, index = 0;
  cin >> n >> v;
  srand(time(NULL));
  for (i = 1; i <= n; i++) {
    cin >> t >> p;
    if (t == 1) {
      kayak[k].p = p;
      kayak[k].pos = i;
      kayak[k].t = t;
      k++;
    } else {
      catamaran[c].p = p;
      catamaran[c].pos = i;
      catamaran[c].t = t;
      c++;
    }
  }
  if (v == 1 && kayak[0].pos == 0) {
    cout << 0;
    cout << endl;
    return 0;
  }
  merge_sort(kayak, 0, k - 1);
  merge_sort(catamaran, 0, c - 1);
  i = 0;
  j = 0;
  n = 0;
  while (volume < v) {
    if (catamaran[i].pos != 0 && volume + 2 <= v) {
      first[n] = catamaran[i];
      volume += 2;
      n++;
      i++;
    } else if (kayak[j].pos != 0) {
      first[n] = kayak[j];
      volume++;
      n++;
      j++;
    } else if (catamaran[i].pos == 0 && kayak[j].pos == 0)
      break;
  }
  n = 0;
  for (index = i - 1; index >= 0; index--)
    if (kayak[j].pos != 0 || kayak[j + 1].pos != 0) {
      if (first[index].p < kayak[j].p + kayak[j + 1].p) {
        output[n] = kayak[j];
        n++;
        j++;
        if (kayak[j].pos != 0) {
          output[n] = kayak[j];
          n++;
          j++;
        }
      } else {
        output[n] = first[index];
        n++;
      }
    } else {
      output[n] = first[index];
      n++;
    }
  while (first[i].pos != 0) {
    output[n] = first[i];
    n++;
    i++;
  }
  for (i = 0; output[i].pos != 0; i++) max += output[i].p;
  cout << max << endl;
  for (i = 0; output[i].pos != 0; i++) cout << output[i].pos << ' ';
  return 0;
}