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;
#pragma GCC optimize("Ofast")
inline long long left(long long p) { return 1 + (p << 1); }
inline long long right(long long p) { return 1 + left(p); }
inline long long LSOne(long long i) { return i & (-i); }
template <typename... T>
void in(T&... args) {
  ((cin >> args), ...);
}
template <typename... T>
void out(T&&... args) {
  ((cout << args << '\n'), ...);
}
const long long MAX_N = 1;
vector<pair<long long, long long> > k, c;
signed main(void) {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  std::cout.tie(NULL);
  long long n, v, t, p;
  in(n, v);
  set<long long> idx;
  for (long long i = 0; i < n; i++) {
    in(t, p);
    if (t == 1)
      k.push_back(make_pair(p, i + 1));
    else
      c.push_back(make_pair(p, i + 1));
  }
  sort(k.begin(), k.end(), greater<pair<long long, long long> >());
  sort(c.begin(), c.end(), greater<pair<long long, long long> >());
  long long p1 = 0, p2 = 1, p3 = 0;
  long long total = 0, cap = 0, num = 0;
  while (p2 < k.size() && p3 < c.size()) {
    if (k[p1].first + k[p2].first >= c[p3].first && (cap + 2) <= v) {
      total += k[p1].first + k[p2].first;
      num += 2;
      cap += 2;
      idx.insert(k[p1].second);
      idx.insert(k[p2].second);
      p1 += 2;
      p2 += 2;
    } else if ((cap + 2) <= v) {
      cap += 2;
      total += c[p3].first;
      num += 1;
      idx.insert(c[p3].second);
      p3++;
    } else
      break;
  }
  if (p3 >= c.size()) {
    for (long long i = p1; i < (long long)k.size() && (cap + 1) <= v; i++) {
      total += k[i].first;
      num++;
      idx.insert(k[i].second);
    }
  } else {
    while (p3 < (long long)c.size() && (cap + 2) <= v) {
      total += c[p3].first;
      num++;
      cap += 2;
      idx.insert(c[p3++].second);
    }
    if (cap + 1 <= v) {
      if (p3 < c.size() && p1 > 0) {
        long long diff = c[p3].first - k[p1 - 1].first;
        if ((p1 < k.size() && diff > k[p1].first)) {
          idx.erase(k[p1 - 1].second);
          total += c[p3].first - k[p1 - 1].first;
          cap += 1;
          idx.insert(c[p3].second);
        } else if (p1 < k.size()) {
          total += k[p1].first;
          cap += 1;
          idx.insert(k[p1].second);
        } else {
          idx.erase(k[p1 - 1].second);
          total += c[p3].first - k[p1 - 1].first;
          cap += 1;
          idx.insert(c[p3].second);
        }
      } else if (p1 < k.size()) {
        total += k[p1].first;
        cap += 1;
        idx.insert(k[p1].second);
      }
    }
  }
  out(total);
  for (auto it : idx) cout << it << " ";
  return 0;
}