#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);
}
pair < ll , vector < ll > > LUU1[36*36+3] , LUU2[36*36+3];
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[cc].fir = v ;
LUU1[cc++].sec=v1;}
else {
LUU2[cc].fir = v ;
LUU2[cc++].sec=v1;
}
}
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 < ll , vector < ll > > a , pair < ll , vector < ll > > b) {
return a.fir < b.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;
Try1( 1 , 0ll , 0ll , v1 , n1 );
int cc1 = cc ;
cc1--;
cc = 1 , v1.clear() ;
Try1(n1 + 1 , 0ll , 0ll , v1 , n);
sort (LUU2 + 1 , LUU2 + cc , cmp) ;
cc--;
for (int i = 1 ; i <= cc ; i ++ )
{
if ( LUU2[cc].fir <= w){
if (LUU2[i].fir > ans )
ans = LUU2[i].fir , k = LUU2[i].sec;
}
}
for (int i = 1 ; i <= cc1 ; i ++ ){
if ( LUU1[cc1].fir <= w){
if ( LUU1[i].fir > ans )
ans = LUU1[i].fir , 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) ;
}
}
}
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;
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);
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgX25oYXRtaW5oICBpbnQgbWFpbigpCiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgc3RyIHN0cmluZwojZGVmaW5lIGZpciBmaXJzdAojZGVmaW5lIHNlYyBzZWNvbmQKI2RlZmluZSBsZCBsb25nIGRvdWJsZQojZGVmaW5lIHBiIHB1c2hfYmFjawojZGVmaW5lIE1PRCAxMDAwMDAwMDkKI2RlZmluZSBmcmVvcGVuKG5hbWUpIGlmKGZvcGVuKG5hbWUiLklOUCIsInIiKS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