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>
typedef short int int16;
typedef int int32;
typedef long long int64;
const double PI = acos(-1.0);
const long long MOD = (long long)1E9 + 7LL;
template <class T>
T Susake_pow(T a, T b) {
  T res;
  if (b == 0)
    return 1;
  else
    while ((b & 1) == 0) {
      b >>= 1;
      a *= a;
    }
  res = a;
  b >>= 1;
  while (b != 0) {
    a *= a;
    if ((b & 1) != 0) res *= a;
    b >>= 1;
  }
  return res;
}
template <class T>
inline T gcd(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  if (a < 0) return lcm(-a, b);
  if (b < 0) return lcm(a, -b);
  return a * (b / gcd(a, b));
}
template <class T>
inline char *Susake_nsystem(T n) {
  T t = 0, i;
  char *s, *p;
  s = (char *)malloc(sizeof(char) * 1000);
  p = (char *)malloc(sizeof(char) * 1000);
  while (n) {
    s[t] = n % 26 + 64;
    if (s[t] == 64) {
      s[t] += 26;
      n -= 26;
    }
    t++;
    n /= 26;
  }
  s[t] = '\0';
  for (i = 0; i < t; i++) p[i] = s[t - 1 - i];
  p[i] = '\0';
  free(s);
  return p;
}
int Susake_system(char *s) {
  int len = strlen(s), i, sum = 0;
  char p[1000];
  for (i = 0; i < len; i++) p[i] = s[len - 1 - i] - 64;
  for (i = 0; i < len; i++) sum += p[i] * Susake_pow(26, i);
  return sum;
}
struct Node {
  int w;
  int num;
};
Node Susake[100006];
Node God[100006];
int a[100006];
int comp(Node a, Node b) { return a.w > b.w ? 1 : 0; }
int main(int argc, char *argv[]) {
  int n, v, v1, v2, t1, t2;
  memset(Susake, 0, sizeof(Susake));
  memset(God, 0, sizeof(God));
  scanf("%d%d", &n, &v);
  t1 = t2 = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &v1, &v2);
    if (v1 == 1) {
      t1++;
      Susake[t1].w = v2;
      Susake[t1].num = i;
    } else {
      t2++;
      God[t2].w = v2;
      God[t2].num = i;
    }
  }
  std::sort(Susake + 1, Susake + t1 + 1, comp);
  std::sort(God + 1, God + t2 + 1, comp);
  int k1 = 1, k2 = 1, j = 0, weight = 0;
  memset(a, 0, sizeof(a));
  if (v % 2 == 1 && Susake[k1].w * 2 > God[k2].w && v >= 1 && k1 <= t1) {
    weight += Susake[k1].w;
    j++;
    a[j] = Susake[k1].num;
    k1++;
    v--;
  }
  while (v) {
    if (k1 > t1 && k2 > t2) break;
    if (k1 + 1 <= t1 && k2 <= t2 && v >= 2) {
      if (Susake[k1].w + Susake[k1 + 1].w > God[k2].w) {
        weight += Susake[k1].w + Susake[k1 + 1].w;
        j++;
        a[j] = Susake[k1].num;
        j++;
        a[j] = Susake[k1 + 1].num;
        k1 += 2;
        v -= 2;
      } else {
        weight += God[k2].w;
        j++;
        a[j] = God[k2].num;
        k2++;
        v -= 2;
      }
    } else if (k2 <= t2 && v >= 2 && k1 + 1 > t1) {
      weight += God[k2].w;
      j++;
      a[j] = God[k2].num;
      k2++;
      v -= 2;
    } else if (k2 > t2 && v >= 1 && k1 <= t1) {
      weight += Susake[k1].w;
      j++;
      a[j] = Susake[k1].num;
      k1++;
      v--;
    } else {
      if (k1 <= t1 && v >= 1) {
        weight += Susake[k1].w;
        j++;
        a[j] = Susake[k1].num;
        k1++;
        v--;
      } else if (k2 <= t2 && v >= 2) {
        weight += God[k2].w;
        j++;
        a[j] = God[k2].num;
        k2++;
        v -= 2;
      } else
        break;
    }
  }
  printf("%d\n", weight);
  if (j > 0) {
    if (j == 1)
      printf("%d\n", a[1]);
    else {
      for (int i = 1; i <= j - 1; i++) printf("%d ", a[i]);
      printf("%d\n", a[j]);
    }
  }
  return 0;
}