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>
struct TData {
 private:
 public:
  using Shared = std::shared_ptr<TData>;
  int _index = 0;
  int _size = 0;
  int _weight = 0;
  bool _paired = false;
  std::pair<Shared, Shared> _pair;
  TData(const TData& a) = delete;
  TData& operator=(const TData& a) = delete;
  TData() {}
  TData(int ind, int sz, int we) : _index(ind), _size(sz), _weight(we) {}
  TData(Shared& a, Shared& b) { makepair(a, b); }
  ~TData() {}
  inline void makepair(Shared& a, Shared& b) {
    _pair.first = a;
    _pair.second = b;
    _index = 0;
    _size = a->_size + b->_size;
    _weight = a->_weight + b->_weight;
    _paired = true;
  }
};
using TVec = std::vector<TData::Shared>;
void printVec(const TVec& vec, bool debug = false) {
  if (debug) {
    printf("----\n");
    for (auto& pr : vec) {
      printf("%d %d %d\n", pr->_index, pr->_size, pr->_weight);
    }
  } else {
    for (auto& pr : vec) printf("%d ", pr->_index);
  }
}
void printVecInLine(int _weight, const TVec& vec) {
  printf("%d : ", _weight);
  for (auto& pr : vec) {
    printf("%d ", pr->_weight);
  }
  printf("\n");
}
void sortVec(TVec& vec, bool reverse = false) {
  std::sort(std::begin(vec), std::end(vec),
            [reverse](const TData::Shared& a, const TData::Shared& b) {
              if (reverse) return a->_weight > b->_weight;
              return a->_weight < b->_weight;
            });
}
void pairBaydarkas(TVec& vec, TVec& outVec) {
  auto vsize = vec.size();
  for (unsigned int i = 0; i < vsize;) {
    if (i + 1 < vsize) {
      outVec.emplace_back(std::make_shared<TData>(vec[i], vec[i + 1]));
      i += 2;
    } else {
      outVec.emplace_back(vec[i]);
      ++i;
    }
  }
}
int main() {
  int n = 0;
  int v = 0;
  scanf("%d %d", &n, &v);
  int sz = 0;
  int we = 0;
  TVec vec1;
  TVec vec2;
  for (int i = 0; i < n; ++i) {
    scanf("%d %d", &sz, &we);
    if (sz == 1)
      vec1.emplace_back(std::make_shared<TData>(i + 1, sz, we));
    else
      vec2.emplace_back(std::make_shared<TData>(i + 1, sz, we));
  }
  int needSize = v;
  int fullWeight = 0;
  TVec vecRes;
  if (needSize == 1) {
    sortVec(vec1, true);
    if (!vec1.empty()) {
      vecRes.emplace_back(vec1[0]);
      fullWeight += vec1[0]->_weight;
    }
  } else {
    vecRes.reserve(vec1.size() + vec2.size());
    sortVec(vec1, true);
    if (v % 2 == 1 && !vec1.empty()) {
      needSize -= vec1[0]->_size;
      fullWeight += vec1[0]->_weight;
      vecRes.emplace_back(vec1[0]);
      TVec vec1_1(vec1.begin() + 1, vec1.end());
      vec1.swap(vec1_1);
    }
    TVec vec3;
    vec3.reserve(vec1.size() / 2);
    pairBaydarkas(vec1, vec3);
    std::copy(std::begin(vec2), std::end(vec2), std::back_inserter(vec3));
    sortVec(vec3, true);
    for (unsigned int i = 0; i < vec3.size() && needSize > 0; ++i) {
      auto& data = vec3[i];
      if (needSize >= data->_size) {
        if (data->_paired) {
          vecRes.emplace_back(data->_pair.first);
          vecRes.emplace_back(data->_pair.second);
        } else {
          vecRes.emplace_back(data);
        }
        needSize -= data->_size;
        fullWeight += data->_weight;
      } else {
        for (unsigned int j = i + 1; j < vec3.size(); ++j) {
          auto& data2 = vec3[j];
          if (data2->_paired) {
            vecRes.emplace_back(data2->_pair.first);
            needSize -= data2->_pair.first->_size;
            fullWeight += data2->_pair.first->_weight;
          } else if (data2->_size == needSize) {
            vecRes.emplace_back(data2);
            needSize -= data2->_size;
            fullWeight += data2->_weight;
          }
        }
      }
    }
  }
  printf("%d\n", fullWeight);
  for (auto& data : vecRes) {
    printf("%d ", data->_index);
  }
  return 0;
}