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;
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double pi = acos(-1.0), eps = 1e-9, e = exp(1.0);
const int INF = 1000 * 1000 * 1000 + 7, MAXN = 100005, MOD = 1000000007,
          MAXBIT = 30, pHash = 53;
const long long INFL = 1e+18;
void prepare(string s) {
  if ((int)s.size() != 0) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
  }
}
struct Superstring {
  string s;
  long long h1[MAXN], h2[MAXN];
  long long pp1[MAXN], pp2[MAXN];
  void read() {
    cin >> s;
    s.insert(s.begin(), ' ');
    countHashes();
  }
  void countHashes() {
    int n = (int)s.size();
    pp1[0] = 1;
    pp2[0] = 1;
    for (int i = 1; i <= n; i++) {
      pp1[i] = pp1[i - 1] * pHash;
      pp2[i] = (pp2[i - 1] * pHash) % MOD;
    }
    h1[0] = s[0] - 'a' + 1;
    h2[0] = (s[0] - 'a' + 1) % MOD;
    for (int i = 1; i < n; i++) {
      h1[i] = h1[i - 1] + pp1[i] * (s[i] - 'a' + 1);
      h2[i] = (h2[i - 1] + pp2[i] * (s[i] - 'a' + 1)) % MOD;
    }
  }
  long long getHash1(int l, int r) {
    long long h = h1[r];
    if (l > 0) h -= h1[l - 1];
    h *= pp1[(int)s.size() - 1 - r];
    return h;
  }
  long long getHash2(int l, int r) {
    long long h = h2[r];
    if (l > 0) h = (h - h2[l - 1] + MOD) % MOD;
    h = (h * pp2[(int)s.size() - 1 - r]) % MOD;
    return h;
  }
};
int n, v, numa, numb;
vector<pair<int, int> > a, b;
long long A[MAXN], B[MAXN], ans;
int binSearch(long long x) {
  int l = -1, r = (int)b.size() + 1;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (2 * mid <= v - x) {
      l = mid;
    } else {
      r = mid;
    }
  }
  return l;
}
void solve() {
  cin >> n >> v;
  for (int i = 0; i < n; ++i) {
    int p, q;
    cin >> p >> q;
    if (p == 1)
      a.push_back(make_pair(q, i + 1));
    else
      b.push_back(make_pair(q, i + 1));
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  for (int i = 1; i <= (int)a.size(); i++) {
    A[i] = A[i - 1] + a[i - 1].first;
  }
  for (int i = 1; i <= (int)b.size(); i++) {
    B[i] = B[i - 1] + b[i - 1].first;
  }
  for (int i = 0; i <= (int)a.size(); i++) {
    if (i > v) break;
    int j = binSearch(i);
    if (A[i] + B[j] > ans) {
      ans = A[i] + B[j];
      numa = i;
      numb = j;
    }
  }
  cout << ans << endl;
  for (int i = 0; i < numa; ++i) cout << a[i].second << ' ';
  for (int i = 0; i < numb; ++i) cout << b[i].second << ' ';
}
int main() {
  prepare("");
  solve();
  return 0;
}