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 <typename T>
inline T abs(T x) {
  return x > 0 ? x : -x;
}
template <typename T>
inline T sqr(T x) {
  return x * x;
}
template <typename T>
inline T max(T a, T b, T c) {
  return max(max(a, b), c);
}
template <typename T>
inline T min(T a, T b, T c) {
  return min(min(a, b), c);
}
template <typename T>
inline T max(T a, T b, T c, T d) {
  return max(max(a, b), max(c, d));
}
template <typename T>
inline bool toMax(T& a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
inline bool toMin(T& a, T b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <typename T, typename T1>
inline T qpower(T x, T p, T1 mod) {
  T re = 1;
  x %= mod;
  while (p) {
    if (p & 1) re = (re * x) % mod;
    x = (x * x) % mod;
    p >>= 1;
  }
  return re;
}
template <typename T1, typename T2>
inline T1 power(T1 x, T2 p) {
  return x < 0 && p < 1 && -1 < p ? p != 0 ? -pow(-x, p) : 1 : pow(x, p);
}
inline bool mr(long long x, long long b) {
  long long k = x - 1;
  while (k) {
    long long cur = qpower(b, k, x);
    if (cur != 1 && cur != x - 1) return false;
    if ((k & 1) == 1 || cur == x - 1) return true;
    k >>= 1;
  }
  return true;
}
inline bool isprime(long long x) {
  if (x == 46856248255981ll || x < 2) return false;
  if (x == 2 || x == 3 || x == 7 || x == 61 || x == 24251) return true;
  return mr(x, 2) && mr(x, 61);
}
template <typename T>
inline void read(T& res) {
  char c;
  res = 0;
  bool f = 0;
  while ((c = getchar()) < 48)
    if (c == '-') f = 1;
  do res = (res << 1) + (res << 3) + (c ^ 48);
  while ((c = getchar()) > 47);
  if (f) res = -res;
}
template <typename T>
inline void write(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 ^ 48);
}
template <typename T>
inline string itos(T x) {
  stringstream ss;
  string str;
  ss << x;
  ss >> str;
  return str;
}
const double PI = acos(-1);
const double e = 2.718281828459;
const long long MOD = 1000000007;
const int MAXN = 100005;
const int MAX = 0x7fffffff;
const int INF = 0xffffffff;
struct Vehicle {
  int c;
  int id;
  Vehicle(int a = 0, int b = 0) {
    c = a;
    id = b;
  }
  bool operator<(const Vehicle& x) const { return c > x.c; }
};
vector<Vehicle> v1(1);
vector<Vehicle> v2(1);
vector<int> sum1(MAXN);
vector<int> sum2(MAXN);
int main() {
  int n, v;
  read(n);
  read(v);
  for (register int i = 1; i <= n; i++) {
    int type, cap;
    read(type);
    read(cap);
    if (type == 1)
      v1.push_back(Vehicle(cap, i));
    else
      v2.push_back(Vehicle(cap, i));
  }
  sort(v1.begin() + 1, v1.end());
  sort(v2.begin() + 1, v2.end());
  for (register int i = 1; i < v1.size(); i++) {
    sum1[i] = v1[i].c + sum1[i - 1];
  }
  for (register int i = 1; i < v2.size(); i++) {
    sum2[i] = v2[i].c + sum2[i - 1];
  }
  int num1 = v1.size() - 1;
  int num2 = v2.size() - 1;
  int maxC = 0;
  int t1, t2;
  int j;
  for (int i = 0; i <= min(v, num1); i++) {
    j = (v - i) / 2;
    if (j > num2) j = num2;
    if (sum1[i] + sum2[j] > maxC) {
      t1 = i;
      t2 = j;
      maxC = sum1[i] + sum2[j];
    }
  }
  cout << maxC << endl;
  if (t1 != 0)
    for (register int t = 1; t <= t1; t++) {
      cout << v1[t].id << " ";
    }
  if (t2 != 0)
    for (register int t = 1; t <= t2; t++) {
      cout << v2[t].id << " ";
    }
  cout << endl;
  return 0;
}