#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 <= x ){
kq = m , l = m + 1 ;
}
else r = m - 1 ;
}
return kq;*/
}
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;
}
}
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 );
if (VI_TRI_CUA_I != -1 ){
ll haha = LUU2[VI_TRI_CUA_I].fir + LUU1[i].fir ;
if ( haha > ans ){
ans = haha ;
k = LUU2[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();
}
_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);
}
I2luY2x1ZGUgPGJpdHMv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AgICAgcmVzICs9IGFbaV0udjsKICAgICAgICAgICAgICAgIHYucGIoaSkgOyAKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoIGRlbSA+IHcpIHJldHVybiA7CiAgICAgICAgfQogICAgICAgIGlmIChyZXMgPiBhbnMpIGFucyA9IHJlcyAsIGsgPSB2IDsKICAgICAgICByZXR1cm47CiAgICB9CiAgICBmb3IgKGludCBqID0gMCA7IGogPD0gMSA7IGogKysgKQogICAgICAgIHhbaV0gPSBqICwgVHJ5KGkrMSk7Cn0KdmVjdG9yPHBhaXIgPCBwYWlyIDwgbGwgLCBsbCA+ICAsIHZlY3RvciA8IGxsID4gPj4gTFVVMSAsIExVVTI7CnZvaWQgc3ViMSgpewogICAgVHJ5KDEpIDsKICAgIGNvdXQgPDwgay5zaXplKCkgPDwgJ1xuJzsKICAgIGZvciAoIGF1dG8geCA6IGsgKSBjb3V0IDw8IHggPDwgJyAnOwp9CmludCBjYyA9IDEgOwppbnQgbjEgOyAKdm9pZCBUcnkxKCBpbnQgaSAsIGxsIHMgLCBsbCB2ICwgdmVjdG9yPGxsPiB2MSAsIGludCBkaWdkaWhvdXNlKSB7CiAgICBpZiAoIGkgPiBkaWdkaWhvdXNlICl7ICAKICAgICAgICBpZiAoIHMgPD0gdyAmJiB2ICE9IDAgKSB7CiAgICAgICAgICAgIGlmICggZGlnZGlob3VzZSA9PSBuMSl7CiAgICAgICAgICAgICAgICBMVVUxLnBiKG1ha2VfcGFpcihtYWtlX3BhaXIocyx2KSx2MSkpOwogICAgICAgICAgICBjYysrO30KICAgICAgICAgICAgZWxzZSB7CiAgICAgICAgICAgICAgICBMVVUyLnBiKG1ha2VfcGFpcihtYWtlX3BhaXIocyx2KSx2MSkpOyBjYysrOwogICAgICAgICAgICB9CiAgICAgICAgfSAgIAogICAgICAgIHJldHVybiA7ICAgICAgICAKICAgIH0KICAgIFRyeTEoaSsxICwgcyAsIHYgLCB2MSAsIGRpZ2RpaG91c2UpOwogICAgaWYgKCBzICsgYVtpXS53IDw9IHcpIHsKICAgICAgICB2MS5wYihpKSA7CiAgICAgICAgVHJ5MShpKzEscythW2ldLncsdithW2ldLnYgLCB2MSAsIGRpZ2RpaG91c2UpOyAKICAgIH0KfQpib29sIGNtcCAocGFpciA8IHBhaXIgPCBsbCAsIGxsID4gICwgdmVjdG9yIDwgbGwgPiA+IGEgLHBhaXIgPCBwYWlyIDwgbGwgLCBsbCA+ICAsIHZlY3RvciA8IGxsID4gPiBiKSB7CiAgICByZXR1cm4gYS5maXIuZmlyIDwgYi5maXIuZmlyIDsKfQppbnQgY2hhdCAoIGxsIHggICl7CiAgICAvKmludCBsID0gMSAsIHIgPSBjYyA7CiAgICBpbnQga3EgPSAtMSA7IAogICAgd2hpbGUgKCBsIDw9IHIgKXsKICAgICAgICBpbnQgbSA9ICggbCArIHIgKSA+PiAxIDsKICAgICAgICBpZiAoIExVVTJbbV0uZmlyIDw9IHggKXsKICAgICAgICAKICAgICAgICAgICAga3EgPSBtICwgbCA9IG0gKyAxIDsKICAgICAgICAKICAgICAgICB9IAogICAgICAgIGVsc2UgciA9IG0gLSAxIDsKICAgIH0KICAgIHJldHVybiBrcTsqLwp9CnZvaWQgc3ViMigpewogICAgdmVjdG9yIDwgbGwgPiB2MSA7IAogICAgbjEgPSBuPj4xOwogICAgTFVVMS5wYihtYWtlX3BhaXIobWFrZV9wYWlyKDAsMCksdjEpKTsKICAgIExVVTIucGIobWFrZV9wYWlyKG1ha2VfcGFpcigwLDApLHYxKSk7CiAgIAogICAgVHJ5MSggMSAsIDBsbCAsIDBsbCAsIHYxICwgbjEgKTsKICAgIGludCBjYzEgPSBjYyA7CiAgICBjYzEtLTsKICAgIGNjID0gMSAsIHYxLmNsZWFyKCkgOwogICAgVHJ5MShuMSArIDEgLCAwbGwgLCAwbGwgLCB2MSAsIG4pOwogICAgc29ydCAoQUxMKExVVTIpLCBjbXApIDsKICAgIGNjLS07IAogICAgCiAgICBmb3IgKGludCBpID0gMSA7IGkgPD0gY2MgOyBpICsrICkKICAgIHsKICAgICAgICBpZiAoIExVVTJbaV0uZmlyLmZpciA8PSB3KXsKICAgICAgICAgICAgaWYgKExVVTJbaV0uZmlyLnNlYyA+IGFucyApCiAgICAgICAgICAgICAgICBhbnMgPSBMVVUyW2ldLmZpci5zZWMgLCBrID0gTFVVMltpXS5zZWM7CiAgICAgICAgfQogICAgfQogICAgZm9yIChpbnQgaSA9IDEgOyBpIDw9IGNjMSA7IGkgKysgKXsKICAgICAgICBpZiAoIExVVTFbaV0uZmlyLmZpciA8PSB3KXsKCiAgICAgICAgICAgICAgICBpZiAoIExVVTFbaV0uZmlyLnNlYyA+IGFucyAgKQogICAgICAgICAgICAgICAgICAgIGFucyA9IExVVTFbaV0uZmlyLnNlYyAsIGsgPSBMVVUxW2ldLnNlYyA7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLyppbnQgVklfVFJJX0NVQV9JID0gY2hhdCAoIHcgLSBMVVUxW2ldLmZpciApOwogICAgICAgICAgICBpZiAoVklfVFJJX0NVQV9JICE9IC0xICl7CiAgICAgICAgICAgIGxsIGhhaGEgPSBMVVUyW1ZJX1RSSV9DVUFfSV0uZmlyICsgTFVVMVtpXS5maXIgOwogICAgICAgICAgICBpZiAoIGhhaGEgPiBhbnMgKXsKICAgICAgICAgICAgICAgIGFucyA9IGhhaGEgOwogICAgICAgICAgICAgICAgayA9IExVVTJbVklfVFJJX0NVQV9JXS5zZWMgOwogICAgICAgICAgICAgICAgZm9yICggYXV0byB4IDogTFVVMVtpXS5zZWMpIGsucGIoeCkgOwogICAgICAgIAogICAgICAgICAgICB9Ki8KICAgICAgICBmb3IgKGludCBqID0gMSA7IGogPD0gY2MgOyBqICsrICl7CiAgICAgICAgICAgIGxsIGhhaGEgPSBMVVUyW2pdLmZpci5maXIgKyBMVVUxW2ldLmZpci5maXIgOwogICAgICAgICAgICBpZiAoIGhhaGEgPiB3KSBicmVhazsKICAgICAgICAgICAgbGwgY2NjY2NjYyA9IExVVTJbal0uZmlyLnNlYyArIExVVTFbaV0uZmlyLnNlYyA7CiAgICAgICAgICAgIGlmICggY2NjY2NjYyA+IGFucyl7CiAgICAgICAgICAgICAgICBhbnMgPSBjY2NjY2NjIDsKICAgICAgICAgICAgICAgIGsgPSBMVVUyW2pdLnNlYyA7CiAgICAgICAgICAgICAgICBmb3IgKCBhdXRvIHggOiBMVVUxW2ldLnNlYykgay5wYih4KSA7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CiAgICBzb3J0ICggQUxMKCBrKSkgOwogICAgY291dCA8PCBrLnNpemUoKSA8PCAnXG4nOwogICAgZm9yICggYXV0byB4IDogayApIGNvdXQgPDwgeCA8PCAnICc7Cn0Kdm9pZCBzb2x2ZSgpewogICAgY2luID4+IG4gPj4gdyA7CiAgICBmb3IgKGludCBpID0gMSA7IGkgPD0gbiA7IGkgKysgKQogICAgICAgIGNpbiA+PiBhW2ldLncgPj4gYVtpXS52OwogICAvLyBpZiAoIG4gPT0gMTUpIGNvdXQgPDwgYVsxNV0udyA8PCAnICcgPDwgYVsxNV0udiA8PCAnXG4nOwogICAgIHN1YjIoKTsKfQpfbmhhdG1pbmh7CmZyZW9wZW4oIiIpOwppb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOwpjaW4udGllKDApOyBjb3V0LnRpZSgwKTsKaW50IHE9MTsKLy8gY2luID4+IHE7CndoaWxlIChxLS0pCiAgICBzb2x2ZSgpOwpjZXJyIDw8ICdcbicgPDwgIlRpbWUgZWxhcHNlZCAiIDw8IFRJTUUgPDwgInMuXG4iOwpyZXR1cm4gKDApOwp9Cg==