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>
const long long MOD = 1000000007;
const double EPS = 1e-4;
using namespace std;
struct mint {
  long long x;
  mint(long long x = 0) : x((x % MOD + MOD) % MOD) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow(MOD - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& V) {
  long long N = V.size();
  if (N == 0) {
    os << '.';
    return os;
  }
  for (long long i = 0; i < N - 1; i++) {
    os << V[i] << ' ';
  }
  os << V[N - 1];
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<vector<T>>& V) {
  long long N = V.size();
  for (long long i = 0; i < N - 1; i++) cout << V[i] << "\n";
  cout << V[N - 1];
  return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> const& P) {
  os << P.first << ' ' << P.second;
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T>& S) {
  auto it = S.begin();
  while (it != S.end()) {
    os << *it;
    if (next(it, 1) != S.end()) os << ' ';
    it++;
  };
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T>& q) {
  for (auto it = q.begin(); it < q.end(); it++) {
    os << *it;
    if (it + 1 != q.end()) os << " ";
  }
  return os;
}
template <typename T>
void Vin(vector<T>& v) {
  long long n = v.size();
  for (long long i = 0; i < n; i++) cin >> v[i];
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long mypow(long long x, long long n, long long m) {
  if (n == 0) return 1;
  if (n % 2 == 0)
    return mypow(x * x % m, n / 2, m);
  else
    return x * mypow(x, n - 1, m) % m;
}
long long scomb(long long n, long long r) {
  if (r < 0 || r > n) return 0;
  if ((n - r) < r) r = n - r;
  long long a = 1;
  for (long long i = n; i > n - r; --i) {
    a = a * i;
  }
  for (long long i = 1; i < r + 1; ++i) {
    a = a / i;
  }
  return a;
}
vector<long long> vis(vector<long long>& v) {
  vector<long long> S(v.size() + 1);
  for (long long i = 1; i < S.size(); i++) S[i] += v[i - 1] + S[i - 1];
  return S;
}
long long digitsum(long long n) {
  long long ret = 0;
  while (n > 0) {
    ret += n % 10;
    n /= 10;
  }
  return ret;
}
long long digit(long long k, long long i) {
  string s = to_string(k);
  return s[s.size() - i] - '0';
}
template <typename T>
void press(T& v) {
  v.erase(unique((v).begin(), (v).end()), v.end());
}
vector<long long> zip(vector<long long> b) {
  long long Z = b.size();
  pair<long long, long long> p[Z + 10];
  long long a = b.size();
  vector<long long> l(a);
  for (long long i = 0; i < a; i++) p[i] = make_pair(b[i], i);
  sort(p, p + a);
  long long w = 0;
  for (long long i = 0; i < a; i++) {
    if (i && p[i].first != p[i - 1].first) w++;
    l[p[i].second] = w;
  }
  return l;
}
vector<long long> nibe2V() {
  vector<long long> a(60);
  long long q = 1;
  for (long long i = 0; i < 60; i++) {
    a[i] = q;
    q *= 2;
  }
  return a;
}
long long modiv(long long a, long long b) {
  return a * mypow(b, MOD - 2, MOD) % MOD;
}
long long SMALLER(vector<long long>& a, long long x) {
  return lower_bound(a.begin(), a.end(), x) - a.begin();
}
long long orSMALLER(vector<long long>& a, long long x) {
  return upper_bound(a.begin(), a.end(), x) - a.begin();
}
long long BIGGER(vector<long long>& a, long long x) {
  return a.size() - orSMALLER(a, x);
}
long long orBIGGER(vector<long long>& a, long long x) {
  return a.size() - SMALLER(a, x);
}
long long COUNT(vector<long long>& a, long long x) {
  return upper_bound((a).begin(), (a).end(), x) -
         lower_bound((a).begin(), (a).end(), x);
}
long long maxind(vector<long long>& a) {
  return max_element((a).begin(), (a).end()) - a.begin();
}
long long minind(vector<long long>& a) {
  return min_element((a).begin(), (a).end()) - a.begin();
}
vector<long long> stpowV() {
  vector<long long> a(1000005);
  a[0] = 1;
  for (long long i = 1; i <= 1000004; i++) a[i] = a[i - 1] * i % MOD;
  return a;
}
struct knapsack {
  long long N, W, ans;
  vector<pair<long long, long long>> goods;
  vector<vector<long long>> dp;
  vector<long long> pick;
  long long max_w, max_v;
  bool limit;
  knapsack(long long n, long long w) { init(n, w); }
  void init(long long n, long long w) {
    N = n;
    W = w;
    max_w = -3000000000000000000;
    max_v = -3000000000000000000;
    ans = 0;
    limit = true;
  }
  void add_goods(long long v, long long w) {
    goods.push_back(make_pair(v, w));
    max_w = max(max_w, w);
    max_v = max(max_v, v);
  }
  long long solve() {
    if (N != goods.size())
      cerr << "WARNING"
           << "\n";
    if (max_w <= 2) return lorry();
    if (W <= 200010) return small_W();
  }
  long long small_W() {}
  long long lorry() {
    ans = 0;
    pick = {};
    long long now_W = W;
    vector<pair<long long, long long>> one, two;
    for (long long i = 0; i < N; i++) {
      if (goods[i].second == 1)
        one.push_back(make_pair(goods[i].first, i));
      else
        two.push_back(make_pair(goods[i].first, i));
    }
    for (long long i = 0; i < 5; i++)
      one.push_back(make_pair(0, 3000000000000000000));
    for (long long i = 0; i < 5; i++)
      two.push_back(make_pair(0, 3000000000000000000));
    sort((one).begin(), (one).end());
    sort((two).begin(), (two).end());
    long long ol = one.size() - 1, tl = two.size() - 1;
    while (1) {
      long long os, ts;
      if (now_W == 0) break;
      os = one[ol].first + one[ol - 1].first;
      ts = two[tl].first;
      if (ts == 0 && os == 0) break;
      if (now_W == 1) {
        now_W--;
        ans += one[ol].first;
        pick.push_back(one[ol].second);
        ol--;
        break;
      }
      if (os <= ts) {
        ans += ts;
        pick.push_back(two[tl].second);
        tl--;
        now_W -= 2;
      } else {
        ans += one[ol].first;
        pick.push_back(one[ol].second);
        ol--;
        now_W -= 1;
      }
      if (now_W == 0) break;
    }
    sort((pick).begin(), (pick).end());
    while (pick.size() > 0 && pick.back() == 3000000000000000000)
      pick.pop_back();
    return ans;
  }
};
signed main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  long long n, w;
  cin >> n >> w;
  knapsack KS(n, w);
  for (long long i = 0; i < n; i++) {
    long long qw, er;
    cin >> qw >> er;
    KS.add_goods(er, qw);
  }
  KS.solve();
  cout << KS.ans << "\n";
  for (long long i = 0; i < KS.pick.size(); i++) KS.pick[i]++;
  if (KS.ans > 0) cout << KS.pick << "\n";
  return 0;
}