#include <bits/stdc++.h>
#define _nhatminh int main()
#define ll long long
#define str string
#define fir first
#define sec second
#define ld long double
#define pb push_back
#define MOD 100000009
#define freopen(name) if(fopen(name".INP","r")) {freopen (name".INP","r",stdin); freopen (name".OUT","w",stdout);}
#define ALL(x) (x).begin(),(x).end()
#define piint pair < int , int >
#define piL pair < int , ll>
#define pLL pair < ll , ll >
#define TIME (1.0*clock()/CLOCKS_PER_SEC)
using namespace std;
const int Max_n=36;
struct cc
{
ll w , v;
};
cc a[Max_n+3] ;
ll x[Max_n+3];
int n ;
ll w ; ll ans = -1e18;
vector < ll > k ;
void Try ( int i ){
if ( i > n ){
std::vector<ll> v;
ll dem = 0 ,res = 0 ;
for (int i = 1 ; i <= n ; i ++ ){
if (x[i]){
dem += a[i].w;
res += a[i].v;
v.pb(i) ;
}
if ( dem > w) return ;
}
if (res > ans) ans = res , k = v ;
return;
}
for (int j = 0 ; j <= 1 ; j ++ )
x[i] = j , Try(i+1);
}
vector<pair < pair < ll , ll > , vector < ll > >> LUU1 , LUU2;
void sub1(){
Try(1) ;
cout << k.size() << '\n';
for ( auto x : k ) cout << x << ' ';
}
int cc = 1 ;
int n1 ;
void Try1( int i , ll s , ll v , vector<ll> v1 , int digdihouse) {
if ( i > digdihouse ){
if ( s <= w && v != 0 ) {
if ( digdihouse == n1){
LUU1.pb(make_pair(make_pair(s,v),v1));
cc++;}
else {
LUU2.pb(make_pair(make_pair(s,v),v1)); cc++;
}
}
return ;
}
Try1(i+1 , s , v , v1 , digdihouse);
if ( s + a[i].w <= w) {
v1.pb(i) ;
Try1(i+1,s+a[i].w,v+a[i].v , v1 , digdihouse);
}
}
bool cmp (pair < pair < ll , ll > , vector < ll > > a ,pair < pair < ll , ll > , vector < ll > > b) {
return a.fir.fir < b.fir.fir ;
}
int chat ( ll x ){
int l = 1 , r = cc ;
int kq = -1 ;
while ( l <= r ){
int m = ( l + r ) >> 1 ;
if ( LUU2[m].fir.fir <= x ){
kq = m , l = m + 1 ;
}
else r = m - 1 ;
}
return kq;
}
pair < ll , vector <ll >> S[262144+5] ;
void sub2(){
vector < ll > v1 ;
n1 = n>>1;
LUU1.pb(make_pair(make_pair(0,0),v1));
LUU2.pb(make_pair(make_pair(0,0),v1));
Try1( 1 , 0ll , 0ll , v1 , n1 );
int cc1 = cc ;
cc1--;
cc = 1 , v1.clear() ;
Try1(n1 + 1 , 0ll , 0ll , v1 , n);
sort (ALL(LUU2), cmp) ;
cc--;
for (int i = 1 ; i <= cc ; i ++ )
{
if ( LUU2[i].fir.fir <= w){
if (LUU2[i].fir.sec > ans )
ans = LUU2[i].fir.sec , k = LUU2[i].sec;
}
S[i].fir = S[i-1].fir;
S[i].sec=S[i-1].sec;
if ( LUU2[i].fir.sec > S[i-1].fir )S[i].fir = LUU2[i].fir.sec,S[i].sec=LUU2[i].sec;
}
for (int i = 1 ; i <= cc1 ; i ++ ){
if ( LUU1[i].fir.fir <= w){
if ( LUU1[i].fir.sec > ans )
ans = LUU1[i].fir.sec , k = LUU1[i].sec ;
}
int VI_TRI_CUA_I = chat ( w - LUU1[i].fir.fir );
if (VI_TRI_CUA_I != -1 ){
ll haha = S[VI_TRI_CUA_I].fir + LUU1[i].fir.sec ;
if ( haha > ans ){
ans = haha ;
k = S[VI_TRI_CUA_I].sec ;
for ( auto x : LUU1[i].sec) k.pb(x) ;
}
}
// for (int j = 1 ; j <= cc ; j ++ ){
// ll haha = LUU2[j].fir.fir + LUU1[i].fir.fir ;
// if ( haha > w) break;
// ll ccccccc = LUU2[j].fir.sec + LUU1[i].fir.sec ;
// if ( ccccccc > ans){
// ans = ccccccc ;
// k = LUU2[j].sec ;
// for ( auto x : LUU1[i].sec) k.pb(x) ;
// }
// }
}
sort ( ALL( k)) ;
cout << k.size() << '\n';
for ( auto x : k ) cout << x << ' ';
}
void solve(){
cin >> n >> w ;
for (int i = 1 ; i <= n ; i ++ )
cin >> a[i].w >> a[i].v;
// if ( n == 15) cout << a[15].w << ' ' << a[15].v << '\n';
sub2();
//cout << ans << ' ';
}
_nhatminh{
freopen("");
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int q=1;
// cin >> q;
while (q--)
solve();
cerr << '\n' << "Time elapsed " << TIME << "s.\n";
return (0);
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgX25oYXRtaW5oICBpbnQgbWFpbigpCiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgc3RyIHN0cmluZwojZGVmaW5lIGZpciBmaXJzdAojZGVmaW5lIHNlYyBzZWNvbmQKI2RlZmluZSBsZCBsb25nIGRvdWJsZQojZGVmaW5lIHBiIHB1c2hfYmFjawojZGVmaW5lIE1PRCAxMDAwMDAwMDkKI2RlZmluZSBmcmVvcGVuKG5hbWUpIGlmKGZvcGVuKG5hbWUiLklOUCIsInIiKSkge2ZyZW9wZW4gKG5hbWUiLklOUCIsInIiLHN0ZGluKTsgZnJlb3BlbiAobmFtZSIuT1VUIiwidyIsc3Rkb3V0KTt9CiNkZWZpbmUgQUxMKHgpICh4KS5iZWdpbigpLCh4KS5lbmQoKQojZGVmaW5lIHBpaW50IHBhaXIgPCBpbnQgLCBpbnQgPgojZGVmaW5lIHBpTCBwYWlyIDwgaW50ICwgbGw+CiNkZWZpbmUgcExMIHBhaXIgPCBsbCAsIGxsID4KI2RlZmluZSBUSU1FICgxLjAqY2xvY2soKS9DTE9DS1NfUEVSX1NFQykKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKY29uc3QgaW50IE1heF9uPTM2OwpzdHJ1Y3QgY2MKewogICAgbGwgdyAsIHY7Cn07CmNjIGFbTWF4X24rM10gOwpsbCB4W01heF9uKzNdOwppbnQgbiA7CmxsIHcgOyBsbCBhbnMgPSAtMWUxODsKdmVjdG9yIDwgbGwgPiBrIDsKdm9pZCBUcnkgKCBpbnQgaSApewogICAgaWYgKCBpID4gbiApewogICAgICAgIHN0ZDo6dmVjdG9yPGxsPiB2OwogICAgICAgIGxsIGRlbSA9IDAgLHJlcyAgPSAwIDsKICAgICAgICBmb3IgKGludCBpID0gMSA7IGkgPD0gbiA7IGkgKysgKXsKICAgICAgICAgICAgaWYgKHhbaV0pewogICAgICAgICAgICAgICAgZGVtICs9IGFbaV0udzsKICAgICAgICAgICAgICAgIHJlcyArPSBhW2ldLnY7CiAgICAgICAgICAgICAgICB2LnBiKGkpIDsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoIGRlbSA+IHcpIHJldHVybiA7CiAgICAgICAgfQogICAgICAgIGlmIChyZXMgPiBhbnMpIGFucyA9IHJlcyAsIGsgPSB2IDsKICAgICAgICByZXR1cm47CiAgICB9CiAgICBmb3IgKGludCBqID0gMCA7IGogPD0gMSA7IGogKysgKQogICAgICAgIHhbaV0gPSBqICwgVHJ5KGkrMSk7Cn0KdmVjdG9yPHBhaXIgPCBwYWlyIDwgbGwgLCBsbCA+ICAsIHZlY3RvciA8IGxsID4gPj4gTFVVMSAsIExVVTI7CnZvaWQgc3ViMSgpewogICAgVHJ5KDEpIDsKICAgIGNvdXQgPDwgay5zaXplKCkgPDwgJ1xuJzsKICAgIGZvciAoIGF1dG8geCA6IGsgKSBjb3V0IDw8IHggPDwgJyAnOwp9CmludCBjYyA9IDEgOwppbnQgbjEgOwp2b2lkIFRyeTEoIGludCBpICwgbGwgcyAsIGxsIHYgLCB2ZWN0b3I8bGw+IHYxICwgaW50IGRpZ2RpaG91c2UpIHsKICAgIGlmICggaSA+IGRpZ2RpaG91c2UgKXsKICAgICAgICBpZiAoIHMgPD0gdyAmJiB2ICE9IDAgKSB7CiAgICAgICAgICAgIGlmICggZGlnZGlob3VzZSA9PSBuMSl7CiAgICAgICAgICAgICAgICBMVVUxLnBiKG1ha2VfcGFpcihtYWtlX3BhaXIocyx2KSx2MSkpOwogICAgICAgICAgICBjYysrO30KICAgICAgICAgICAgZWxzZSB7CiAgICAgICAgICAgICAgICBMVVUyLnBiKG1ha2VfcGFpcihtYWtlX3BhaXIocyx2KSx2MSkpOyBjYysrOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiA7CiAgICB9CiAgICBUcnkxKGkrMSAsIHMgLCB2ICwgdjEgLCBkaWdkaWhvdXNlKTsKICAgIGlmICggcyArIGFbaV0udyA8PSB3KSB7CiAgICAgICAgdjEucGIoaSkgOwogICAgICAgIFRyeTEoaSsxLHMrYVtpXS53LHYrYVtpXS52ICwgdjEgLCBkaWdkaWhvdXNlKTsKICAgIH0KfQpib29sIGNtcCAocGFpciA8IHBhaXIgPCBsbCAsIGxsID4gICwgdmVjdG9yIDwgbGwgPiA+IGEgLHBhaXIgPCBwYWlyIDwgbGwgLCBsbCA+ICAsIHZlY3RvciA8IGxsID4gPiBiKSB7CiAgICByZXR1cm4gYS5maXIuZmlyIDwgYi5maXIuZmlyIDsKfQppbnQgY2hhdCAoIGxsIHggICl7CiAgICBpbnQgbCA9IDEgLCByID0gY2MgOwogICAgaW50IGtxID0gLTEgOwogICAgd2hpbGUgKCBsIDw9IHIgKXsKICAgICAgICBpbnQgbSA9ICggbCArIHIgKSA+PiAxIDsKICAgICAgICBpZiAoIExVVTJbbV0uZmlyLmZpciA8PSB4ICl7CgogICAgICAgICAgICBrcSA9IG0gLCBsID0gbSArIDEgOwoKICAgICAgICB9CiAgICAgICAgZWxzZSByID0gbSAtIDEgOwogICAgfQogICAgcmV0dXJuIGtxOwp9CnBhaXIgPCBsbCAsIHZlY3RvciA8bGwgPj4gU1syNjIxNDQrNV0gOwp2b2lkIHN1YjIoKXsKICAgIHZlY3RvciA8IGxsID4gdjEgOwogICAgbjEgPSBuPj4xOwogICAgTFVVMS5wYihtYWtlX3BhaXIobWFrZV9wYWlyKDAsMCksdjEpKTsKICAgIExVVTIucGIobWFrZV9wYWlyKG1ha2VfcGFpcigwLDApLHYxKSk7CgogICAgVHJ5MSggMSAsIDBsbCAsIDBsbCAsIHYxICwgbjEgKTsKICAgIGludCBjYzEgPSBjYyA7CiAgICBjYzEtLTsKICAgIGNjID0gMSAsIHYxLmNsZWFyKCkgOwogICAgVHJ5MShuMSArIDEgLCAwbGwgLCAwbGwgLCB2MSAsIG4pOwogICAgc29ydCAoQUxMKExVVTIpLCBjbXApIDsKICAgIGNjLS07CgogICAgZm9yIChpbnQgaSA9IDEgOyBpIDw9IGNjIDsgaSArKyApCiAgICB7CiAgICAgICAgaWYgKCBMVVUyW2ldLmZpci5maXIgPD0gdyl7CiAgICAgICAgICAgIGlmIChMVVUyW2ldLmZpci5zZWMgPiBhbnMgKQogICAgICAgICAgICAgICAgYW5zID0gTFVVMltpXS5maXIuc2VjICwgayA9IExVVTJbaV0uc2VjOwogICAgICAgIH0KICAgICAgICBTW2ldLmZpciA9IFNbaS0xXS5maXI7CiAgICAgICAgU1tpXS5zZWM9U1tpLTFdLnNlYzsKICAgICAgICAgaWYgKCBMVVUyW2ldLmZpci5zZWMgPiBTW2ktMV0uZmlyIClTW2ldLmZpciA9IExVVTJbaV0uZmlyLnNlYyxTW2ldLnNlYz1MVVUyW2ldLnNlYzsKICAgIH0KICAgIGZvciAoaW50IGkgPSAxIDsgaSA8PSBjYzEgOyBpICsrICl7CiAgICAgICAgaWYgKCBMVVUxW2ldLmZpci5maXIgPD0gdyl7CgogICAgICAgICAgICAgICAgaWYgKCBMVVUxW2ldLmZpci5zZWMgPiBhbnMgICkKICAgICAgICAgICAgICAgICAgICBhbnMgPSBMVVUxW2ldLmZpci5zZWMgLCBrID0gTFVVMVtpXS5zZWMgOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGludCBWSV9UUklfQ1VBX0kgPSBjaGF0ICggdyAtIExVVTFbaV0uZmlyLmZpciApOwogICAgICAgICAgICBpZiAoVklfVFJJX0NVQV9JICE9IC0xICl7CiAgICAgICAgICAgIGxsIGhhaGEgPSBTW1ZJX1RSSV9DVUFfSV0uZmlyICsgTFVVMVtpXS5maXIuc2VjIDsKICAgICAgICAgICAgaWYgKCBoYWhhID4gYW5zICl7CiAgICAgICAgICAgICAgICBhbnMgPSBoYWhhIDsKICAgICAgICAgICAgICAgIGsgPSBTW1ZJX1RSSV9DVUFfSV0uc2VjIDsKICAgICAgICAgICAgICAgIGZvciAoIGF1dG8geCA6IExVVTFbaV0uc2VjKSBrLnBiKHgpIDsKCiAgICAgICAgICAgIH0KICAgICAgICB9Ci8vICAgICAgICBmb3IgKGludCBqID0gMSA7IGogPD0gY2MgOyBqICsrICl7Ci8vICAgICAgICAgICAgbGwgaGFoYSA9IExVVTJbal0uZmlyLmZpciArIExVVTFbaV0uZmlyLmZpciA7Ci8vICAgICAgICAgICAgaWYgKCBoYWhhID4gdykgYnJlYWs7Ci8vICAgICAgICAgICAgbGwgY2NjY2NjYyA9IExVVTJbal0uZmlyLnNlYyArIExVVTFbaV0uZmlyLnNlYyA7Ci8vICAgICAgICAgICAgaWYgKCBjY2NjY2NjID4gYW5zKXsKLy8gICAgICAgICAgICAgICAgYW5zID0gY2NjY2NjYyA7Ci8vICAgICAgICAgICAgICAgIGsgPSBMVVUyW2pdLnNlYyA7Ci8vICAgICAgICAgICAgICAgIGZvciAoIGF1dG8geCA6IExVVTFbaV0uc2VjKSBrLnBiKHgpIDsKLy8gICAgICAgICAgICB9Ci8vICAgICAgICB9CiAgICB9CiAgICBzb3J0ICggQUxMKCBrKSkgOwogICAgY291dCA8PCBrLnNpemUoKSA8PCAnXG4nOwogICAgZm9yICggYXV0byB4IDogayApIGNvdXQgPDwgeCA8PCAnICc7Cn0Kdm9pZCBzb2x2ZSgpewogICAgY2luID4+IG4gPj4gdyA7CiAgICBmb3IgKGludCBpID0gMSA7IGkgPD0gbiA7IGkgKysgKQogICAgICAgIGNpbiA+PiBhW2ldLncgPj4gYVtpXS52OwogICAvLyBpZiAoIG4gPT0gMTUpIGNvdXQgPDwgYVsxNV0udyA8PCAnICcgPDwgYVsxNV0udiA8PCAnXG4nOwogICAgIHN1YjIoKTsKICAgLy9jb3V0IDw8IGFucyA8PCAnICc7Cn0KX25oYXRtaW5oewpmcmVvcGVuKCIiKTsKaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTsKY2luLnRpZSgwKTsgY291dC50aWUoMCk7CmludCBxPTE7Ci8vIGNpbiA+PiBxOwp3aGlsZSAocS0tKQogICAgc29sdmUoKTsKY2VyciA8PCAnXG4nIDw8ICJUaW1lIGVsYXBzZWQgIiA8PCBUSU1FIDw8ICJzLlxuIjsKcmV0dXJuICgwKTsKfQo=